what is class of tab bar item - iphone

When I connect element from xib to header file. It gives me
#property (strong, nonatomic) IBOutlet UITabBarItem *contract;
#property (strong, nonatomic) IBOutlet UITabBarItem *history;
However, when I try to print out the subiew of my tabBar ( type of UITabBar), I am getting 2 UITabBarButton.
My question is what is class of tab bar item.Is it UITabBarItem or UITabBarButton

Firstly: what you're doing is not recommended. You're not meant to rely on private subviews of Apple views, as they can change at any time.
To actually answer the question as posed, it's because UITabBarItem is not actually a view, so won't ever end up in your view hierarchy. What presumably happens somewhere in the UITabBar code is, the UITabBarItems are iterated through, and for each one the system makes a new view of class UITabBarButton, which is a private subclass of UIControl.
You're never meant to access a UITabBarButton directly. As BoltClock was pointing out in the comments, you should rethink your design so that you don't need to do this.

Related

Declaration of a button process

I would like to understand the process of the declaration of a button.
#interface MerdaViewController : UIViewController{
IBOutlet UIButton *button;
}
#property (retain, nonatomic) IBOutlet UIButton *button;
#end
Why do we need those steps?
Is it always required?
Thank you so much.
Alex.
To create a button outlet you just need this line.
#property (retain, nonatomic) IBOutlet UIButton *button;
To create button action
-(IBAction)doSomething:(id)sender;
Just like to add another point:
Outlets should generally be weak/assign, except for those from File’s Owner to top-level objects in a nib file (or, in iOS, a storyboard scene) which should be strong/retain
at least in relatively new versions of XCode, you don't need to declare that instance variable. It's automatically taken care of.
you need the #property so you can call self.button and do whatever you like to it. IBOutlet tells XCode it's an element in your interface builder, so you can hook it up with that visual button you added to IB.
more often than not I find myself actually declaring an -(IBAction)buttonAction:(id)sender; rather than an IBOutlet. This way when you tap that button, the IBAction method is automatically triggered.

How to add tabbar in cameraView of zbar sdk

I'm a newbie in iphone app developing, I just started learning two weeks ago due to the need of my final project.
So please forgive me if my question seems really stupid.
I've searched in forums and zbar documentation about how to customize the cameraView.
But I still didn't have a clear understanding about how to do it.
Now I'm trying to add tabbar into the cameraView, could anybody tell me how to do it?
I know that I need to use overlay and create my own view, adding the reader as a subview in it. Could anybody give me some direction more explicitly about how to reaise it?
Thanks in advance!!
You have to create your own custom UITabBarController class. And add this controller in your custom camera view. and custom camera view is created by the AVFoundation framework.
From what I know, you need to add the tabbar to the appDelegate and then inner views within each tab. Therefore you would have within the appdelegate applicationDidFinishLoading method
// Add the tab bar controller's view to the window and display.
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
of course, you need to declare it in the appdelegate.h file
#interface AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
Search for tabBar tutorials. They must be created BEFORE any NAVIGATION Controller.
Then place all your zbar code in the first view controller.

Connect one view to another in seperate NIBs using Interface Builder

I have a custom UIWindow class that has an IBOutlet
#interface MyWindow
IBOutlet UIView * someView;
id <MyWindowDelegate> delegate;
// to inform a controller something happened to view
#end
#interface MyControllerThatContainsSomeView
IBOutlet UIWebView * theConcreteView;
#end
I have changed my Window in MainWindow.xib to MyWindow. Is there a way, through interface builder, in which I can reference someView from MyControllerThatContainsSomeView.xib
so, MainWindow.MyWindow.someView -> MyControllerThatContainsSomeView.theConcreteView
You can refer to it in a binding path but that's about it. Usually when you find that you need to refer from one view to another, it's time to rethink your design. Views should refer instead to model objects which provide data to the views.

Objective-C Novice. Change property in Controller from another Controller?

The context: I have three views. One Introductory view, an Upload view and the Main view. As classes (With their respective headers) I have the rootViewController (SwitchViewController), IntroViewController and UploadViewController. The first view to be shown is IntroView. The user presses a button (declared in SwitchViewController) that takes them to the UploadView, then in the UploadView they get to choose an image and press the button again to go back to IntroView.
The thing is that while the user gets to pick the image with UIImagePickerController the button to switch views won't hide nor a UIImageView I have with a logo on top of the view(screen). The UIImageView and the UIButton are both declared in SwitchViewController's header.
The code used:
UploadViewController.h
#import [...] //Imports
#class SwitchViewController;
#interface UploadViewController :
UIViewController <UIImagePickerControllerDelegate,
UINavigationControllerDelegate,UIActionSheetDelegate> {
UITextField *imageTextField;
UIImageView *uploadedImage;
SwitchViewController *switchViewController;
[...]
}
#property (nonatomic, retain) SwitchViewController *switchViewController;
#property (nonatomic, retain) IBOutlet UITextField *imageTextField;
#property (nonatomic, retain) IBOutlet UIImageView *uploadedImage;
[...]
#end
UploadViewController.m
[...]
- (IBAction) selectImageButtonPressed {
self.switchViewController.submitButton.hidden = YES;
self.switchViewController.imageLogo.hidden = YES;
[...] //continues
I just begun recently programming in objective-c so please forgive me if the question is very essential. I have looked and am following "Beginning iPhone 3 Development" of APRESS. But even if it helps to greatly understand the basics sometimes I get lost.
PS: If it is clearer to answer the question the SwitchViewController.h and .m snippet codes can be provided if asked. But I thought this text is big as it is.
#Joze i think I may have understood your problem switchViewController is a variable of the class UploadViewController so if you do anything with that variable it wont affect the switchViewController view. so when you are calling the switchViewController view at that time you have to do initWithNibName: bundle: and then hide the button and imageView and also you need to do something like switchViewController.delegate = self; and then call the view modally or what ever way you want it.
PS. i m not sure the that spelling is correct. i dont have xcode at my home.
I hope your problem solves with this.
I solved my problem after refactoring the whole code and changing the general structure of the program itself. Now I have 3 views and each with a viewController to control it. All the switching of views occurs in the Delegate since he has access to everyone. That way I can control every property with every controller, without much difficulty. Changing the property of one of the objects present in one view from another view is difficult and rather inconvenient if not sometimes impossible.
The approach I took when asking this question was short sighted for the application that had to be done. I thank all those who tried to help.

iPhone Development - multiple views in one window.

I want to have a UIView at the top half of my app, and a UITable at the bottom half. If I create a basic window application I can do this using IB. My main problem is that I seem to be only to do this in the delegate file which I would like to avoid.
I repeat the exact same steps I did in delegate in a separate controller and all I get is a blank screen.
0#interface RootViewController : UIWindow {
UIWindow *myWindow;
UIView *headerView;
UITableView *tableView;
}
#property (nonatomic, retain) IBOutlet UIView *headerView;
#property (nonatomic, retain) IBOutlet UITableView *tableView;
#property (nonatomic, retain) IBOutlet UIWindow *myWindow;
#end
I have each of these connect to the right view in rootviewcontroller.xib
I was wondering if anyone had any advice / snippets / examples I could use?
You need to use both the delegate file and Interface Builder. Interface Builder makes a view that binds to your delegate through IBOutlets and IBActions. I would run through several iPhone tutorials found on google before continuing.
Your RootViewController certainly shouldn't be a subclass of UIWindow. You probably want UIViewController for that.