Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Requirement of my app is to have UINavigationController at the bottom with play, rewind and stop buttons on it. Play button will play audio and will have multiple ViewControllers. what should be the code to display UINavigationController at the bottom
UINavigationController should generally go at the top of the view (as per the H.I.G.).
A bar at the bottom should be a UIToolbar where you create your own buttons (UIBarButtonItem) and give them to the toolbar.
UIBarButtonItem has default items for Play, Stop, and Rewind (and many others)
If you already use a navigation controller, you can show its default toolbar (setToolbarHidden:NO) and create/set the items in the same way.
UINavigationController is a container that maintains a stack of UIViewControllers and a NavigationBar. You could try using the UINavigationBar separate, but you'd likely be better off just making some custom graphics on an imageView at the bottom.
Got it with the frame definition display it at the bottom like
MyCustomNavigationBar *navigationBar = [[MyCustomNavigationBar alloc] initWithFrame:CGRectMake(0, 435, 320, 25)];
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a view with several UIButton instances. Now I'd like that the user can trigger als button when he wishes over it with a long touch. So he can either touch one button or wishe over several buttons. Therefore all button actions of the touched buttons should be executed.
Here's a photo (buttons with red background color and black border):
Thanks for your help!
Best regards from Bavaria,
Chris
If I understand the question right, what you need with your grid of buttons is UIPanGestureRecognizer.
You can add the same recognizer to every instance of UIButton and handle all its states (UIGestureRecognizerStateBegan, UIGestureRecognizerStateChanged, UIGestureRecognizerStateEnded).
If you want certain delay in detection (like UILongPressGestureRecognizer), you can trigger timer and check if finger is still inside the UIButton's frame.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to implement a custom switch in a project. Currently what I have found is that we cannot alter with UISwitch in way to implement as shown in below image. I've followed posts and googled through stackoverflow and other blogs but didn't found a solution as desired. One way is to go with UISegmented control as in this post, but that too doesn't solves my problem.
Thanks in advance for any help
It's not hard to create your own switch. A UISwitch is a control — essentially just a view that sends a message — with two states. You could set it up your own custom control like this:
container view: a simple view with rounded corners (set the cornerRadius of the view's layer) and a background color
left image: an image view that displays the image you want to show on the left side, i.e. the check mark for your example
right image: an image view that displays the image you want to show on the right side, i.e. the X mark for your example
slider: an image view showing the slider portion of the switch, set above the other two image views
When the user taps or swipes the control, use Core Animation to move the slider to the other side of the switch and update the state of the control and do a quick fade to the background color for the new state. Send the control's action to the target.
As gasparuff says, you can also do it with a UIButton, just set the images:
[button setImage:[UIImage imageNamed:#"image_on"] forState:UIControlStateSelected];
[button setImage:[UIImage imageNamed:#"image_off"] forState:UIControlStateNormal];
and when it's tapped just toggle the selected property.
- (void) buttonTap {
button.selected = !button.selected;
}
Which will change the images automatically.
You know about -[UISwitch setOnImage:] and -[UISwitch setOffImage:], right? Also -[UISwitch setTintColor]. About the only drawback I can see is that the switch, itself, will be the standard iOS switch (round button) but, otherwise, this would be the most-iOS-like solution.
When implementing your own on/offImage, remember the size restrictions, and also that the side of the image toward the switch is concave. tintColor can be used to make the rest of the switch reflect your color scheme. You might want to track the valueChanged event so alter the tint color.
If you need the exact look you display in your question (square switch button), then you probably want to use a custom control, as #Caleb suggested.
It looks like you just want your control to have only 2 states - enabled and disabled.
An easy way for this would be to create 2 png-images and use a custom UIButton with a background image and just replace those 2 images each time the button is tapped.
Is this what you are trying to do or did I misunderstand something?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is it possible to have the following?
When I rotate my iOS Device, the ViewController switches, as in I have RandomViewControllerPortrait and RandomViewControllerLandscape. I have the feeling that if I support both orientations, that the ViewController class gets quite "bloated".
Is this idea useful at all?
I think having 2 view controllers for different rotations would be a bit redundant. I think what you want to use is 2 different UIViews for different orientations, and your UIViewController handling the methods for rotations being called. When your application rotates, you can set self.view to be either portraitView or landscapeView. You can even animate the view change with an animation block, so the transition looks smoother.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Further to this question here, I'm really interested in creating my own UITabBar, and 'rolling my own'. Im really curious as to how this is done, especially in an app such as the Twitter app.
How can I do this? Can anyone point to any good resources on how to subclass this?
Should I do it programmatically, or in a XIB?
Edit: I'm looking to do this with custom icons/selected icons and having icons only.
Edit2: After reading further answers, it sounds like a custom XXTabBarcontroller is what I actually want to do here. Can anyone comment on this?
Thank you,
I don't know if there is a best way to do this, but I will share my experience:
I created my own version of a tab bar by subclassing UIView as opposed to UITabBar. As the linked question mentions, Apple's UI classes are quite finicky about their sizing and I do not think I could get the UITabBar subclass to size as I wanted.
Because I did not have a subclass of UITabBar I also ended up rolling my own versions of UITabBarController and UITabBarDelegate, with interfaces that are essentially the same as the Apple classes. I WAS able to use UITabBarItem to store the title and icon for the buttons on the tab bar, which is useful since UIViewControllers have a tabBarItem property. That lets you store just an array of UIViewControllers in your controller, as opposed to arrays for both controllers and tab bar items.
Because I was using mostly custom classes I did this all programmatically, including creating, configuring and laying out the buttons on the tab bar.
Like I said, this is just my experience, hope it helps.
I did this recently in an application. There was so little "code" to it that there is barely anything to post. I did it as such:
Created a UIImageView (about 50 px high), and laid it out at the bottom of the screen. I filled it with a tab-bar look-alike image - i.e. some sort of grey gradient. I probably subclassed UIImageView - but you don't even have to do that.
I drew a bunch of buttons/icons - 37x37 each.
I placed a bunch of UIButtons in the "tab bar" - and made them "Custom" views, with the buttons/icons I had created.
I simply used the touchUpInside methods to make them do stuff.
When I needed to get fancy - I'd attach the buttons to my code via and IBOutlet, so I could "disable" them - and I'd draw a greyish "disabled state" image for them.
If you want the same functionality, I'd recommend using a UITabBarController, hide the tab bar itself, and then create your own navigation. I've done this a few times and it works quite nicely.
Use something like this to hide your tab bar and expand the content view.
- (void)makeTabBarHidden:(BOOL)hide
{
if ( [tabBarController_.view.subviews count] < 2 )
return;
UIView *contentView;
if ( [[tabBarController_.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
contentView = [tabBarController_.view.subviews objectAtIndex:1];
else
contentView = [tabBarController_.view.subviews objectAtIndex:0];
if (hide)
{
contentView.frame = tabBarController_.view.bounds;
}
else
{
contentView.frame = CGRectMake(tabBarController_.view.bounds.origin.x,
tabBarController_.view.bounds.origin.y,
tabBarController_.view.bounds.size.width,
tabBarController_.view.bounds.size.height - tabBarController_.tabBar.frame.size.height);
}
tabBarController_.tabBar.hidden = hide;
}
Then make your own navigation with UIButtons to switch between your view controllers.
[tabBarController_ setSelectedIndex:0];
I think this is what you are looking for... should be pretty easy to subclass it. gl and cheer!
http://www.rumexit.co.uk/2010/07/how-to-customise-the-tab-bar-uitabbar-in-an-iphone-application-part-1-of-2/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
while i am scrolling my table view gets moving upwards ..
i hav created table view programmatically without using IB so i should able to fix the position of table view while scrolling also...
how to do this..
any suggestions appreciated..
Do you mean you dont want the table to scroll at all? If so then this should do it.
tableView.scrollEnabled = NO;
Are you embedding a UITableView in a UIScrollView? It sounds like it. Don't. UITableView is already a subclass of UIScrollView and supports scrolling on its own.