I was using UIWebview to play a video in portrait mode. It was working fine in case of iphone OS 3.2 .
Some times ago i updated my iphone OS to 4.0 then problem came(No video player is coming now). My current build version of application is 3.1.2.
Thanks a lot for any kind of help.
I am not sure if this is an option for you, and you probably know about that. but beginning with iOS 3.2 you can rotate MPMovieController (or MPMovieViewController) without going to fullscreen, and you do not need to use a UIWebView for that.
kind regards,phil.
You need to set the allowsInLineMediaPlayback of a webview to yes. To make your code run across all platforms you could use the following code:
//check if the system os version is higher than 3.2
NSString *os_verson = [[UIDevice currentDevice] systemVersion];
NSLog(os_verson);
if([os_verson localizedCompare:#"3.2"] != NSOrderedAscending)
{
self.webView.allowsInlineMediaPlayback = YES;
}
Related
Just finished up my iPhone appln, now wants to use same appln for creating an iPad version. What i really want to do is to detect which on which device the app is running and accordingly pick UI at runtime. I get some code regarding which is my current device. Basically main idea behind is that is i don't want to write the server-client communication part again for separate ipad version. Ui is different hence I don't want to create a universal app for this.
My Prob: What settings should I do to make to work the application as described above. Currently when I run using iPhone Simulator, It says tht my current device is iPhone. But, when I changed my device to iPad Simulator and than run it back again, it convert that int iphone simulator.
Thanks.
you can check with this line:
NSString *model = [[NSString alloc]initWithString:[[UIDevice currentDevice] model]];
model value would be either iPhone or iPad
or you can go with [[UIDevice currentDevice] userInterfaceIdiom] and compare the values with
typedef enum {
UIUserInterfaceIdiomPhone,
UIUserInterfaceIdiomPad,
} UIUserInterfaceIdiom;
Recently submitted iPhone and iPod Touch application to app store successfully, but later came to know that is not working on iPad 3.2 but works on iPad with high iOS like 4 in scaled version.
Reason: setOrientation property of Movie player.
Actual Query: In order to make it work on iPad 3.2 in MAC Desktop I used
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
player.view.frame = CGRectMake(0, 0, 768, 1024);
[self.view addSubview:player.view];
[player play];
}
else {
#ifdef __IPHONE_4_0
player.controlStyle = MPMovieControlStyleNone;
#else
[player setOrientation:UIDeviceOrientationPortrait animated:NO];
}
when i run the same code on my MAC BOOK with iOS 3.0 this code is throwing the error...not supported.
So
If i build the above code on MAC DESKTOP(with iOS 4) will that work
on iPhone device with iOS 3.0 ? ..in reference to Event Kit Frame
Work(which throws error in iOS 3.0..but required in iOS 4).
I need to go for separate iPad app instead of Universal?
Is there any difference in iPhone with iOS 3.2 and iPad with iOS 3.2 in terms of
properties used?
I don't think you should hardcode it like that at compile time. Instead you should test if a particular class or method/property on a class exists and then do the appropriate thing. Like using [NSObject respondstoSelector:] to test whether your object understands a particular method.
Okay, first of all it does not matter if you use the Mac desktop or the MacBook to compile. It looks like you may be confusing the "minimum iOS" value and the "base SDK".
Base SDK: Refers to the code library that the complier will use to check your code, but does not determine which OS's your app will actually run on. You can have a base SDK of 5.0 and your app may still work fine on a 3.0 system. The catch is that if you are using code that is compatable with your Base SDK and not older OS's, the compiler will not catch it.
Minimum OS: This value does determine which OS's your app will run on.
If you are using code for higher OS's but want to run on lower OS's you need to test in the code for which OS you are running on and then run the appropriate code for that platform.
I have an opengl application that renders better in RetinaDisplay mode (double scale factor) and I noticed the iPad emulates an iPhone app with a low resolution screen (normal scale factor).
I want to double the scale factor when my iPhone app is run on an iPad, in order to benefit from Retina Display graphics. But it seems the iPad really well fakes being an iPhone (which would be perfect if only it was a Retina Display one...)
When I force the double scale, it works very well (at least in simulator, I do not have an iPad to test).
So I need a way to know if I am run on an iPad despite many things telling me it to be an old iPhone.
Or maybe I should not try to do that ?
If the app is an iPhone app running in the emulator mode on an iPad, it will have a userInterfaceIdiom of Phone, but a model type of iPad. You can check this with the following code:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone &&
[[[UIDevice currentDevice] model] hasPrefix:#"iPad"]) {
// This app is an iPhone app running on an iPad
}
If you are looking to make custom code (most likely custom UI related methods) for the iPad only then you can use (as Apple directs) the UI_USER_INTERFACE_IDIOM() method that exists in iOS 3.2 and later
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// The device is an iPad running iPhone 3.2 or later.
}
else
{
// The device is an iPhone or iPod touch.
}
You can read more here http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BuildTimeConfiguration/BuildTimeConfiguration.html
This is the Apple recommended method
Look up in the documentation, UIDevice:
For instance something like:
NSString *system = [[UIDevice currentDevice] systemName];
Then by using [system isEqualToString:#"iPad"] whether its an ipad or not.
UIDevice is a very nice class, it also has stuff like multiTaskingSupported, systemVersion etc. gotta love UIKit ;)
i think it is that:
// Set hello to "Hello, <device or simulator>"!
if TARGET_IPHONE_SIMULATOR
NSString *hello = #"Hello, iOS Simulator!";
else
NSString *hello = #"Hello, iOS device!";
endif
the link apple doc
about
This actually will only tell you if
the app is being run in a simulated
environment, or on an actual device,
and has no influence on whether the
platform is iPad or iPhone.
In fact it says at compile time the target of the platform you are compiling for, thus before run you know and do the necessary for take care of something specific.
For example I have diferent URL for developing (running on simulator) and for production usage, so I do some like
#if TARGET_IPHONE_SIMULATOR
#define URL #"http://192.x.x.x/request"
#else
#define URL #"http://example.com/request"
#endif
you shouldn't be able to tell the difference, if its an iPhone app, then as far as it can tell it is running on an iPhone. if you want to target an iPad, then you need to build it for an iPad target.
i am created Universal application, in that i used UIModalPresentationFull, for displaying MFMailComposerSheet in iPad, which helps me to show the full screen of a MailComposer view in landscape view of ipad. When i run the application in ipad simulator i works well. If i set it to iPhone simulator 3.0 or 3.1.3 it shows the error like "error: 'UIModalPresentationFullScreen' undeclared (first use in this function)" when i comment it and run in iPhone simulator it works what would be the solution for this error or, else is that any method replaces "UIModalPresentationFull" works in both ipad and iphone?
Thanks and regards
Venkat
UIModalPresentationFullScreen is only available in the 3.2 (and above) SDK so you can't compile it with a SDK lower than that.
However, you don't need to for a universal application - you compile it against the highest SDK you are going to run on and then you have to check at run-time if the methods / classes you are using are available. You set this in your build settings : Base SDK should be set to the highest SDK you are using (probably 3.2 for the iPad) and iPhone OS Deployment Target should be set to 3.0 - the lowest SDK on which your code can run.
You should be doing this each time you use a 3.2 only bit of code :
if ([controller respondsToSelector:#selector(setModalPresentationStyle:)])
[controller setModalPresentationStyle:UIModalPresentationFullScreen];
Then, even though you have compiled against the 3.2 SDK, when you run it on lower SDK devices, this method will not be run.
I test this on an iphone that still has 3.0 SDK on it. I don't know exactly how you would test in the simulator with a lower SDK sorry.
enter code here
Using conditional compilation block we can isolate the process for iPhone and iPad
" #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 "
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// The device is an iPad running iPhone 3.2 or later.
if ([picker respondsToSelector:#selector(setModalPresentationStyle:)])
{
//picker.modalPresentationStyle = UIModalPresentationFullScreen;
[picker setModalPresentationStyle:UIModalPresentationFullScreen];
}
}
" #endif "
Please remove the quotes and use that if and else part too...(i.e)conditional compilation block
So I'm currently using UI_USER_INTERFACE_IDIOM in conjunction with [[UIDevice currentDevice] model] to check if I'm on an iPhone, iPod or iPad. What I've found is that in the iPad simulator 3.2, UI_USER_INTERFACE_IDIOM still evaluates to UIUserInterfaceIdiomPhone (iPhone).
I'm wondering if this has something to do with my Targeted Device Family setting. I'm only targeting iPhone for my App (I don't want to make a universal app with scaling views). However, I support the 3.2 SDK so I still want users that have an iPad to be able to run my iPhone app.
Will UI_USER_INTERFACE_IDIOM evaluate correctly on the iPad even when I'm targeting iPhone?
UI_USER_INTERFACE_IDIOM does not check if the device is an iPhone or iPad. What it checks is whether the user interface is in iPhone mode (the 1x/2x thing) or iPad mode.
If an app isn't configured to target iPad, it will always return UIUserInterfaceIdiomPhone because the UI is an iPhone app. It is a feature by design.
And even if the app is configured to target iPhone only, the iPad should be able to run it without any problems as long as you use the methods as documented.
(If you need iPad-specific capabilities, do not check whether the device really is an iPad. Instead, check for individual capability.)
Best I can offer is that on the iPad simulator (3.2) while running in "iPhone" mode the
NSLog(#"model : %#", [UIDevice currentDevice].model);
returns
model : iPhone Simulator
(as a note: I am building for "iPhone" only and thus running in the iPhone experience on iPad. I have to assume the "model" name returned is affected by that)
As people have said, check the individual capability.
For making a call, do this
// Only show the button if its is a device capable of making calls
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tel:"]]) {
self.Button.hidden = NO;
} else {
self.Button.hidden = YES;
}