2 XIB and 1 viewcontroller but functions don't work in the ipad XIB

不打扰是莪最后的温柔 提交于 2019-12-10 11:48:23

问题


I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will.

I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects ( enlarged ;-) ) . I added the callbacks to function correctly with IB.

I can see everything fine and arrive on my new ipad view BUT when I click on one of my buttons... nothing happened like if my callbacks don't work. It is very surprising and actually I have no idea where to look as I compared most of the parameters between my iphone and ipad view and they are identical as far as I can see.

It must be something damn obvious so if one of you had the same issue and it was a very simple answer ... I guess that would be what I missed!

Thanks for your help in advance

Cheers, geebee

EDIT1: Some code as requested

at start I have that to decide either way:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
   examTFVC_NIB=@"ExamTFViewController-iPad";
 }
else
{
   examTFVC_NIB=@"ExamTFViewController";
 }

Then to go to the right view:

    ExamTFViewController *examTFViewController = [[ExamTFViewController alloc]                        
                                                  initWithNibName:globals.examTFVC_NIB bundle:nil];

But I have no problem loading the correct XIB. The issue is really the callback functions not being called...

Thanks for the help.

EDIT2: I also realised that calling the extension of the xib xxx~ipad allows to avoid the example code above. And it works - but still no function can be called.

EDIT3: IMPORTANT FINDING: if I move my buttons higher and on the left of the screen: they work! So it seems that the functions are called if the event are in the region of an iphone screen although I am on an ipad screen. I guess know it would be more obvious to find the issue! thanks for any help – geebee just now

ANSWER

iPad touch detected only in 320x480 region

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

// to correct region size
CGRect rect = [[UIScreen mainScreen] bounds];
[window setFrame:rect]; 

// now, display your app
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}

** OR OTHER SOLUTION **

Check the full screen at launch checkbox - only present in the ipad xib MainWindow


回答1:


finally solved - with 2 methods - programmatically or via IB - in the edited section of the post.



来源:https://stackoverflow.com/questions/9982674/2-xib-and-1-viewcontroller-but-functions-dont-work-in-the-ipad-xib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!