I am creating an iPad application that behaves like a power point presentational. I am creating several slides and each slides contains several images with basic functionality. Because I am creating so many slides it will be nice if I can create the IBOutles programmatically since I place so many buttons per slide for instance. it takes a while to place those outlets and create the connections. How can I speed up this process?
Why not just create every item programmatically?
Take a UIButton for example.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:#selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:#"Hello" forState:UIControlStateNormal];
button.frame = CGRectMake(40.0, 200.0, 170.0, 40.0);
[self.view addSubview:button];
This should be of interest to you: http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/030-Edit_User_Interfaces/edit_user_interface.html#//apple_ref/doc/uid/TP40010215-CH6-SW1
There's even a nice video tutorial if you click: "To create and connect a new outlet ..."
Good luck!
Related
I am doing one piano application. There i am using button action to play music. But its not supporting drag functionalities. I have used touchesMoved(),touchBegan() methods also . But nothigh is working.Can anyone help me, please?
Button supports drag functionality. You should add your target by below control events.
[button addTarget:target action:#selector(action1) forControlEvents:UIControlEventTouchDragInside];
[button addTarget:target action:#selector(action2) forControlEvents:UIControlEventTouchDragOutside];
[button addTarget:target action:#selector(action3) forControlEvents:UIControlEventTouchDragExit];
[button addTarget:target action:#selector(action4) forControlEvents:UIControlEventTouchDragEnter];
Implement proper actions for each event and it should identify proper drag event.
I know there is three20 solution. But I don't want to use three20 just for that purpose. So programmingly, is there a solution for that?
Yes there is a solution. You can use the regular expression to detect particular kind of strings on touches began of the label and then based on the regular expression which matches the string you can perform the action.
So if you want to do that, you need to subclass the UILabel and overwrite the Touch methods for the label.
Hope this helps you.
There is one of the Label's called OHAttributedLabel which does similar function. And here is a fork, that supports ARC.
You can use a UIButton with the button type as UIButtonTypeCustom, on the button click you can call the url.
UIButton *urlButton = [UIButton buttonWithType:UIButtonTypeCustom];
urlButton.frame = CGRectMake(10, 10, 80, 30);
[urlButton setTitle:#"Click Here" forState:UIControlStateNormal];
[urlButton addTarget:self action:#selector(urlButtonClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:urlButton];
Currently i am working on a iPhone Application Which is displaying video. I have used MPMoviePlayController to load the Video from the local folder.
Can we customize the Standard media player ? What i want to do is to hide all the standard elements (Play, Forward, Rewind, Done) and just to build the player with a single play button with a customized image . Can anybody help me ?
You can surely add custom controls for MPMoviePlayerController. For that first hide existing controls using, MPMovieControlStyle, set this to MPMovieControlStyleNone
Now add your custom control buttons and handle all the MoviePlayer events over there, like;
Play
Pause
Stop
Prev
Next, etc.
Or you can add your own controls like jump to this time (+10 sec, +20 sec), movie speed control (1x, 2x, ..), etc.
Hope this will be useful for you.
if you want to have any controlStyle of apple and still want to add some custom buttons on movie view. You can subclass MPMoviePlayerViewController.
Let say you have MyCustomMoviePlayerViewController as subclass of MPMoviePlayerViewController then in MyCustomMoviePlayerViewController.m
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:#selector(aMethod:)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:#"MyCustomButton" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview :button];
}
I've got a UIButton that i want to look exactly the same when it's in its disabled state as when it's in its Normal state. Right now it has a slight greyed out look to it.
Do not use enabled property or setEnabled:NO method, instead use:
[myButton setUserInteractionEnabled:NO];
That would prevent the button for being touched, but without changing his looks!
The other way is if your button is a custom button and has an image:
[button setImage:someImage forState:UIControlStateNormal];
[button setImage:someImage forState:UIControlStateDisabled];
[button setEnabled:NO];
How to make a UIImageView open a URL in Safari when user clicks it?
I would suggest using a button for this purpose instead. You can create a custom UIButton with whatever image you want. This gives the advantage of providing the built-in target-action mechanism of a button, as well as being able to provided a highlighted image to provide the user feedback. Consider using something like this:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:#"regular_image.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:#"highlighted_image.png"] forState:UIControlStateHighlighted];
[button addTarget:self action:#selector(loadURL) forControlEvents:UIControlEventTouchUpInside];
Note that it will still look like "just an image" to the user.