But IsPhone check that current device - is iPhone. But IsPad check that current interface idiom is Pad. On iPad we can has two idiom together. For example, for application which is runned on iPad as iPhone application will have iPhone idiom of interface
Ярослав Бровин I'm aware of both those UIDevice members. I was questioning whether the issue of both idioms being available on 1 device was proven/documented, and neither link appears to make any mention of this. So my question stands.
class function DeviceHardware.IsIPad: Boolean; var currentDevice: UIDevice; begin currentDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice); Result := currentDevice.model.rangeOfString(NSSTR('iPad')).location <> NSNotFound end;
class function DeviceHardware.IsIPhone: Boolean; var currentDevice: UIDevice; begin currentDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice); Result := currentDevice.model.rangeOfString(NSSTR('iPhone')).location <> NSNotFound end;
class function DeviceHardware.IsIPod: Boolean; var currentDevice: UIDevice; begin currentDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice); Result := currentDevice.model.rangeOfString(NSSTR('iPod')).location <> NSNotFound end;
Oh, I just looked at the FMX.Helpers.iOS iSPhone function and it does the same as the phone test I just posted. I don't have an iPad to test whether the pad one works or not. I was possibly getting confused with the content of hardware property that iOS devs normally use to do this job. If someone can tell me if the iPad/iPod versions work or not, then if not I'll post a fuller unit that has working (but less general) code.
Hi, You can use FMX.Helpers.iOS IsPhone and IsPad function or use nextcode:
ReplyDeleteResult := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).userInterfaceIdiom = UIUserInterfaceIdiomPad;
But IsPhone check that current device - is iPhone. But IsPad check that current interface idiom is Pad. On iPad we can has two idiom together. For example, for application which is runned on iPad as iPhone application will have iPhone idiom of interface
ReplyDeleteIs that hypothesis, or have you verified this as fact?
ReplyDeleteBrian Long i know about it.
ReplyDeleteYour doubts you can dispel here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/userInterfaceIdiom
Brian Long and there:
ReplyDeletehttps://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/clm/UIDevice/currentDevice
Ярослав Бровин I'm aware of both those UIDevice members. I was questioning whether the issue of both idioms being available on 1 device was proven/documented, and neither link appears to make any mention of this. So my question stands.
ReplyDeleteBrian Long I don't know about existence documentation about it. Because this feature is only for iOS devices
ReplyDeleteSomething like this, then?
ReplyDeleteclass function DeviceHardware.IsIPad: Boolean;
var
currentDevice: UIDevice;
begin
currentDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
Result := currentDevice.model.rangeOfString(NSSTR('iPad')).location <> NSNotFound
end;
class function DeviceHardware.IsIPhone: Boolean;
var
currentDevice: UIDevice;
begin
currentDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
Result := currentDevice.model.rangeOfString(NSSTR('iPhone')).location <> NSNotFound
end;
class function DeviceHardware.IsIPod: Boolean;
var
currentDevice: UIDevice;
begin
currentDevice := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
Result := currentDevice.model.rangeOfString(NSSTR('iPod')).location <> NSNotFound
end;
Oh, I just looked at the FMX.Helpers.iOS iSPhone function and it does the same as the phone test I just posted. I don't have an iPad to test whether the pad one works or not. I was possibly getting confused with the content of hardware property that iOS devs normally use to do this job.
ReplyDeleteIf someone can tell me if the iPad/iPod versions work or not, then if not I'll post a fuller unit that has working (but less general) code.
Hi Brian,
ReplyDeleteit is working - just checked on iPad mini in my lunch break :-)
Can you tell me where I can find more information on the wrap method?
The source :o)
ReplyDeleteWrap takes an Objective-C object pointer and wraps it into a suitable Delphi object, if appropriate
Thanks for the answer - and in the JNI area it would take a Java object pointer I guess.
ReplyDeleteIndeed!
ReplyDeletetry this:
ReplyDeletevar
_xDevice: IFMXDeviceService;
begin
_xDevice := TplatformServices.Current.GetPlatformService(IFMXDeviceService) as IFMXDeviceService;
if Pos('iPad', _xDevice.GetModel) > 0 then
begin
//Bla Bla
end;
Ivane Katsitadze
ReplyDeleteUndeclared IFMXDeviceService
which file i need to use for declaration?
Qhy not use the FMX.Helpers.iOS isPad and isPhone-functions?
ReplyDeleteRoland Kossow
ReplyDeleteIt's not work in my case i don't know why
Can you try with the project under this link?
ReplyDeletehttps://docs.google.com/file/d/0B_mUUtJe8v84YmRFUkJ0dlF3Nkk/edit?usp=sharing
[edited was wrong link]
If it should not work wih the built-in functions you should QC the issue.
ReplyDeleteThe interface Ivane referred to can be found in FMX.Platform .
Roland Kossow
ReplyDeleteI can't open your project
Roland Kossow
ReplyDeleteIvane Katsitadze
It's work correct, thanks.