Exception with TabBar in iPhone SDK - objective-c

A friend gave me a small tutorial to iPhone programming yesterday.
I then tried to make a small program with two views which I can switch using a TabBar: One with a blue background, one with a red one.
It displays them just fine, but when I run it (in the Simulator) and click on a Tab, it crashed with :
"Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'*** -[NSMachPort
_tabBarItemClicked:]: unrecognized selector sent to instance 0x38223e0"
I didn't manage to find the bug so far... Have you got any ideas ? :)
Code from DemoAppDelegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window makeKeyAndVisible];
UIColor *color = [UIColor blueColor];
DemoAppViewController *controller1 = [[DemoAppViewController alloc] initWithColor:color];
color = [UIColor redColor];
DemoAppViewController *controller2 = [[DemoAppViewController alloc] initWithColor:color];
[controller1 updateBackground];
[controller2 updateBackground];
UITabBarController *tbcontroller = [[UITabBarController alloc] init];
NSMutableArray *array = [NSMutableArray arrayWithObjects: controller1, controller2, nil];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:#"Blue" image:nil tag:1];
[controller1 setTabBarItem: item];
[item release];
item = [[UITabBarItem alloc] initWithTitle:#"Red" image:nil tag:2];
[controller2 setTabBarItem: item];
[item release];
[tbcontroller setViewControllers:array];
[tbcontroller setSelectedIndex:0];
[window addSubview: [tbcontroller view]];
[tbcontroller release];
[controller1 release];
[controller2 release];
}
Code excerpt from DemoAppViewController:
- (DemoAppViewController *) initWithColor:(UIColor *)color
{
self = [super init];
if (self != nil) {
[color retain];
backgroundColor = color;
}
return self;
}
- (void) updateBackground
{
UIView *view = [self view];
[view setBackgroundColor: backgroundColor];
}

The problem seems to be in this line: [tbcontroller release];
This is deallocating your tbcontroller. I've commented out that line of code and it works. Try making sure to retain your controller somewhere else since apparently adding the subview isn't doing the job. It may also be related to the viewcontroller themselves being released.

Related

iOS 7 Tab bar icons temporarily disappear when on More tab

When I add a view controller embedded by navigation controller, to a tab bar, its icon + title disappear briefly when coming back to the More tab.
However when the view controller is added as such, the icon+image are okay and don't disappear.
I've tried many things already, and am out of options. Any ideas?
Here's my AppDelegate code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.tabBarController = [[UITabBarController alloc] init];
// Must be placed here, just before tabs are added. Otherwise navigation bar
// will overlap with status bar.
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
[self addViewControllersToTabBar];
self.window.rootViewController = self.tabBarController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)addViewControllersToTabBar
{
NSArray* tabBarClassNames =
#[
NSStringFromClass([FirstViewController class]),
NSStringFromClass([SecondViewController class]),
NSStringFromClass([FirstViewController class]),
NSStringFromClass([FirstViewController class]),
NSStringFromClass([FirstViewController class]),
NSStringFromClass([SecondViewController class]),
NSStringFromClass([FirstViewController class]),
];
NSMutableArray* viewControllers = [NSMutableArray array];
for (NSString* className in tabBarClassNames)
{
UIViewController* viewController = [[NSClassFromString(className) alloc] init];
UINavigationController* navigationController;
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewControllers addObject:navigationController];
}
[viewControllers addObject:[[FirstViewController alloc] init]]; // This one is fine.
self.tabBarController.viewControllers = viewControllers;
self.tabBarController.selectedViewController = viewControllers[2];
}
and the view controllers are literally nothing more than:
#implementation SecondViewController
- (instancetype)init
{
if (self = [super init])
{
self.title = #"second";
self.tabBarItem.image = [UIImage imageNamed:#"second.png"];
}
return self;
}
#end
Holy shit, spent so much time on this bug, but here's my workaround. Instead of:
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
I created my own NavigationController as subclass of UINavigationController:
#implementation NavigationController
- (instancetype)initWithRootViewController:(UIViewController*)rootViewController
{
if (self = [super initWithRootViewController:rootViewController])
{
NSString* className = NSStringFromClass([rootViewController class]);
NSString* name = [className stringByReplacingOccurrencesOfString:#"ViewController" withString:#""];
self.tabBarItem.image = [UIImage imageNamed:[NSString stringWithFormat:#"%#Tab.png", name]];
}
return self;
}
#end
and then do:
navigationController = [[NavigationController alloc] initWithRootViewController:viewController];
Prerequisite is that tab images have the same base name as the view controller class name, which was already the case in my app.
I was setting self.tabBarItem.image inside the view controllers' init method, and this seems to cause the effect I was seeing. So in addition to using my own navigation controller, I also simply deleted setting the tabBarItem in each individual view controller.

Add custom UIButton to UIKeyboard's accessory view for a UIWebView

I need to add a camera button to a UIWebView's keyboard accessory view toolbar (the one that already has the "Back|Next" and "Done" buttons).
Is there an easy way to do this?
I'm still looking for a better way to do it, but one solution for the moment would be to destroy the bar and recreate it like so :
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
NSURL *aURL = [NSURL URLWithString:#"http://www.google.com"];
NSURLRequest *aRequest = [NSURLRequest requestWithURL:aURL];
[web loadRequest:aRequest];
[self.view addSubview:web];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
- (void)keyboardWillShow:(NSNotification *)notification {
[self performSelector:#selector(removeBar) withObject:nil afterDelay:0];
}
- (void)removeBar {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:#"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:#"UIWebFormAccessory"].location != NSNotFound) {
UISegmentedControl *nav = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:#"Previous",#"Next", nil]];
nav.momentary = YES;
nav.frame = CGRectMake(5, 8, 120, 30);
nav.segmentedControlStyle = UISegmentedControlStyleBar;
nav.tintColor = [UIColor colorWithWhite:0.25 alpha:1];
[nav addTarget:self action:#selector(navigate) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *pictureBtn =[[UIBarButtonItem alloc] initWithTitle:#"Picture" style:UIBarButtonItemStyleBordered target:self action:#selector(takePic:)];
UIBarButtonItem *flexButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *doneButton =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(resignKeyboard)];
NSArray *buttons = [NSArray arrayWithObjects:flexButton,pictureBtn,flexButton,doneButton, nil];
[(UIToolbar *)subviewWhichIsPossibleFormView addSubview:nav];
[(UIToolbar *)subviewWhichIsPossibleFormView setItems:buttons];
}
}
}
}
}
But then, you have to implement the previous, next and done function again. But it's not the hardest part.
there is an easier way to do this.
Keep your keyboard notification in your viewDidLoad
After that all you will need is the following method:
-(void)keyboardDidShow:(NSNotification*)notif
{
NSArray *array = [[UIApplication sharedApplication] windows];
for (UIWindow* wind in array) {
for (UIView* currView in wind.subviews) {
if ([[currView description] hasPrefix:#"<UIPeripheralHostView"]) {
for (UIView* perView in currView.subviews) {
if ([[perView description] hasPrefix:#"<UIWebFormAccessory"]) {
UIBarButtonItem *doneBttn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(resignKeyBoard)];
NSMutableArray *arr = [[NSMutableArray alloc] initWithArray: [(UIToolbar *) perView items]];
[arr addObject:doneBttn];
[(UIToolbar *) perView setItems:arr];
}
}
}
}
}
}
I have basically taken the original prev/next buttons from the UIWebFormAccessory and added a done button to the end of it, but you can add what ever buttons you want to this.
Some may think this shouldn't be implemented in -(void)keyboardDidShow: because you are changing the UI after it displays on screen, but so far I haven't noticed any issues with this. (only tested in simulator)
Hope this was useful!

Xcode Unrecognized Selector Error

I've been having a ton of issues with this section of an app that I'm writing, I'm sure people here are getting sick of me so I'm going to try and solve all my questions in this post. I'm working on an app that behaves like a photo gallery, and I'm implementing the option to have the user delete photos from their gallery. To accomplish this, I decided to place an invisible button over each picture. When the user hits an "Edit" button, the hidden delete buttons over each picture become active. I'm using the same IBOutlet over each of the hidden buttons for simplicity, and I've tagged each button appropriately in Interface Builder. When the user taps the button over the picture, an alert view appears asking if they really want to delete it. If they click yes, I call removeObjectAtIndex and delete the image from the UI. But, when I click "Yes" in the alert view, I get an error from Xcode stating:
2012-04-04 11:26:40.484 AppName[608:f803] -[UIButton setImage:]: unrecognized selector sent to instance 0x6a922c0
2012-04-04 11:26:40.485 AppName[608:f803] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton setImage:]: unrecognized selector sent to instance 0x6a922c0'*
I've been trying to figure out what is causing this for a few hours now to no avail. I'm not setting the image of a UIButton anywhere in my code. I did in IB, but I simply set the buttons types to Custom so that they appear invisible. I will post my entire file below, I can't find any issues in my code, so any help is much appreciated! Thanks.
EDIT Here is the current version of the code:
- (IBAction)grabImage {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
_popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
[_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else {
[self presentModalViewController:imgPicker animated:YES];
}
[self.imgPicker resignFirstResponder];
}
// Sets the image in the UIImageView
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
if (imageView.image == nil) {
imageView.image = img;
self.array = [NSMutableArray arrayWithObject:[NSData dataWithData:UIImagePNGRepresentation(imageView.image)]];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView2.image == nil) {
imageView2.image = img;
NSLog(#"The image is a %#", imageView);
[self.array addObject:[NSData dataWithData:UIImagePNGRepresentation(imageView2.image)]];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView3.image == nil) {
imageView3.image = img;
[self.array addObject:[NSData dataWithData:UIImagePNGRepresentation(imageView3.image)]];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView4.image == nil) {
imageView4.image = img;
[self.array addObject:[NSData dataWithData:UIImagePNGRepresentation(imageView4.image)]];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(#"Photo Gallery", #"Photo Gallery");
self.tabBarItem.image = [UIImage imageNamed:#"42-photos.png"];
}
return self;
}
////start of saving////
- (void)applicationDidEnterBackground:(UIApplication*)application {
NSLog(#"Image on didenterbackground: %#", imageView);
self.array = [NSMutableArray arrayWithObject:[NSData dataWithData:UIImagePNGRepresentation(imageView.image)]];
[self.array addObject:[NSData dataWithData:UIImagePNGRepresentation(imageView2.image)]];
[self.array addObject:[NSData dataWithData:UIImagePNGRepresentation(imageView3.image)]];
[self.array addObject:[NSData dataWithData:UIImagePNGRepresentation(imageView4.image)]];
[self.user setObject:self.array forKey:#"images"];
[user synchronize];
}
- (void)viewDidLoad
{
self.user = [NSUserDefaults standardUserDefaults];
NSLog(#"It is %#", self.user);
self.array = [[self.user objectForKey:#"images"]mutableCopy];
imageView.image = [[UIImage alloc] initWithData:[self.array objectAtIndex:0]];
imageView2.image = [[UIImage alloc] initWithData:[self.array objectAtIndex:1]];
imageView3.image = [[UIImage alloc] initWithData:[self.array objectAtIndex:2]];
imageView4.image = [[UIImage alloc] initWithData:[self.array objectAtIndex:3]];
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:app];
backToGalleryButton.hidden = YES;
tapToDeleteLabel.hidden = YES;
deleteButton1.hidden = YES;
[super viewDidLoad];
}
///// shows the hidden and invisible "delete" button over each photo.
- (IBAction)editButtonPressed:(id)sender {
grabButton.hidden = YES;
editButton.hidden = YES;
backToGalleryButton.hidden = NO;
tapToDeleteLabel.hidden = NO;
deleteButton1.hidden = NO;
}
////
// This is when the user taps on the image to delete it.
- (IBAction)deleteButtonPressed:(id)sender {
NSLog(#"Sender is %#", sender);
UIAlertView *deleteAlertView = [[UIAlertView alloc] initWithTitle:#"Delete"
message:#"Are you sure you want to delete this photo?"
delegate:self
cancelButtonTitle:#"No"
otherButtonTitles:#"Yes", nil];
[deleteAlertView show];
int imageIndex = ((UIButton *)sender).tag;
deleteAlertView.tag = imageIndex;
}
- (void)alertView: (UIAlertView *) alertView
clickedButtonAtIndex: (NSInteger) buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex]) {
NSLog(#"User Clicked Yes. Deleting index %d of %d", alertView.tag, [array count]);
NSLog(#"The tag is %i", alertView.tag);
[self.array removeObjectAtIndex: alertView.tag];
NSLog(#"After deleting item, array count = %d", [array count]);
NSLog(#"Returned view is :%#, in view: %#", [self.view viewWithTag:alertView.tag], self.view);
((UIImageView *)[self.view viewWithTag:alertView.tag]).image =nil;
}
[self.user setObject:self.array forKey:#"images"];
}
Update: I added breakpoints, and discovered that ((UIImageView *)[self.view viewWithTag:alertView.tag]).image =nil; is the line that is causing the crash, I still can't figure out why though.
I don't see setImage: being called in any of that code you pasted into your question, but I can tell you this: UIButton's setImage method actually requires a button state as a second parameter.
e.g.
[UIButton setImage: forState:]
I've linked Apple's documentation for you.
If your calls to setImage: don't have a second parameter, that would explain the "unrecognized selector error" you're seeing.
This is an extension to #MichaelDautermann , who makes a very good point that a UIButton has a setImage:forState: method, but no setImage method. However, you ARE calling set image. Not on a button, but when you say imageView.image and imageView2.image. This invokes the setter method for the image view. I would set a breakpoint (or use NSLog and the %# item) to ensure that imageView is in fact an imageView and not a button. If it somehow changed from under you, this could be causing the issue. Simply set a break point at those two lines and see if you even make it past them.
Additionally, if Xcode isn't popping you over to which line is actually causing the issue, check your crash logs. Symbolicated, the log will give you the line number. Or, a less direct approach would be to set breakpoints at the ends of the methods you provided in your answer, and see how many you get past. Once you crash, you can narrow down which method is causing you grief, and then start setting break points within the method until you get to the line in question.
UPDATE:
You said in the comments that ((UIImageView *)[self.view viewWithTag:alertView.tag]).image =nil is what you have, but self.view is a UIControl. Changing the cast won't affect the result. Is the UIImageView whose image you are trying to delete a subview of a UIControl? If not, you're never going to get the image view back from viewWithTag. Generally, self.view refers to a view controller's view, so if you're getting a UIControl, my assumption is either your whole view is a UIControl, or you're doing this in the wrong class. Which class are you doing this in, and what is it a subclass of? It appears you are doing this in a view controller, but I just want to be sure. And again, in either case (UIControl or UIImageView), neither class responds to setImage.

reading a value from preferences

I have just recently implemented the inAppSettings kit. My goal was to load my default view and then add a navigation bar button item to the right called "settings". Once the user pressed the settings button it would take them to my settings bundle where they would make a choice to which website they wanted, and then press back which would load up my default view once again with webview loaded once again with the new url.
I have implemented everything that I just described above but once the selection is made within the settings and the user presses back (aka dismisses the settings view to go back to the default view), the app crashes and I have no idea why. My code is below and if anyone knows why this is happening, it would be much appreciated. Let it be noted that once I run the app again after it crashes, the website loads correctly based on the settings they chose before it crashed.
P.S. the options the user can click to select are: Google, stackoverflow.
ERROR Message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Upcoming settingsViewControllerDidEnd:]: unrecognized selector sent to instance 0x281c70'
Thank you in advance
- (IASKAppSettingsViewController*)appSettingsViewController {
if (!appSettingsViewController) {
appSettingsViewController = [[IASKAppSettingsViewController alloc] initWithNibName:#"IASKAppSettingsView" bundle:nil];
appSettingsViewController.delegate = self;
}
return appSettingsViewController;
}
-(IBAction)selectSettings {
UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:self.appSettingsViewController];
//[viewController setShowCreditsFooter:NO]; // Uncomment to not display InAppSettingsKit credits for creators.
// But we encourage you not to uncomment. Thank you!
self.appSettingsViewController.showDoneButton = YES;
[self presentModalViewController:aNavController animated:YES];
[aNavController release];
}
-(NSDictionary *)intialDefaults {
NSArray *keys = [[[NSArray alloc] initWithObjects:kPicture, nil] autorelease];
NSArray *values= [[[NSArray alloc] initWithObjects: #"none", nil] autorelease];
return [[[NSDictionary alloc] initWithObjects: values forKeys: keys] autorelease];
}
-(void)setValuesFromPreferences {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults registerDefaults:[self intialDefaults]];
NSString *picturePreference= [userDefaults stringForKey:kPicture];
if([picturePreference isEqualToString:#"google"]) {
[self getUpcoming:#"http://www.google.ca"];
} else
if ([picturePreference isEqualToString:#"stackoverflow"]) {
[self getUpcoming:#"http://www.stackoverflow.com"];
} else {
[self getUpcoming:#"http://www.yahoo.com"];
}
}
-(void)getUpcoming:(id) hello {
NSURL *url= [NSURL URLWithString:hello];
NSURLRequest *requestURL= [NSURLRequest requestWithURL:url];
[web loadRequest:requestURL];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
web.hidden=NO;
[spinner stopAnimating];
[load_message dismissWithClickedButtonIndex:0 animated:TRUE];
pic1.hidden=YES;
}
-(void) loadMethod {
load_message = [[UIAlertView alloc] initWithTitle:#"Loading..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
spinner= [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(135.0, 60.0);
[load_message addSubview:spinner];
[load_message show];
[spinner startAnimating];
[self performSelector:#selector(setValuesFromPreferences) withObject:nil afterDelay:0.0];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIBarButtonItem *settingButton= [[UIBarButtonItem alloc]
initWithTitle:#"Settings"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(selectSettings)];
self.navigationItem.rightBarButtonItem = settingButton;
web.hidden=YES;
pic1.hidden=NO;
}
- (void) viewDidAppear:(BOOL)animated {
[self loadMethod];
}
Do you implement the InAppSettingKit delegate? Add this to your current class above
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender
{
// dismiss the view here
[self dismissModalViewControllerAnimated:YES];
// do whatever you need to do
}

iPad Won't Load Modal View

I'm getting this error when loading a modal view.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x72785a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aboutTableView.'
It works perfectly fine from the iPhone, but I'm having this trouble with the iPad.
- (IBAction)showOptionsMenu
{
self.optionsNavController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.optionsNavController.modalPresentationStyle = UIModalPresentationFormSheet;
self.optionsNavController.modalInPopover = YES;
[self presentModalViewController:self.optionsNavController animated:YES];
}
Update:
This works but the UIButton is not being displayed:
MoreViewController *svc = [[[MoreViewController alloc] init] autorelease];
optionsNavController= [[UINavigationController alloc] initWithRootViewController:svc];
self.optionsNavController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.optionsNavController.modalPresentationStyle = UIModalPresentationFormSheet;
self.optionsNavController.modalInPopover = YES;
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithTitle:#"Done" style:UIBarButtonItemStyleBordered target:self action:#selector(dissmissView)];
self.optionsNavController.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];
[self presentModalViewController:self.optionsNavController animated:YES];
Here is a good way to launch a modal view for both devices:
#define IDIOM UI_USER_INTERFACE_IDIOM()
#define IPAD UIUserInterfaceIdiomPad
SomeViewController *svc = [[[SomeViewController alloc] init] autorelease];
if ( IDIOM == IPAD ) {
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:svc];
[controller setModalPresentationStyle:UIModalPresentationFormSheet];
[controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:controller animated:YES];
[controller release];
} else {
/* or you can present the view as modal: */
[self.navigationController pushViewController:svc animated:YES];
}
SomeViewController
-(void)viewDidLoad
{
[super viewDidLoad];
if ( IDIOM == IPAD ) {
UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self action:#selector(dismiss)] autorelease];
self.navigationItem.leftBarButtonItem = doneButton;
}
}
-(void)dismiss
{
[self dismissModalViewControllerAnimated:YES];
}
Are you using different xibs for iphone/ipad?
If so check your connections in your iPad version there is probably a handing connection that you have not removed.