Giter Club home page Giter Club logo

sdversion's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdversion's Issues

enum DeviceSize error in XCode6.1

My project runs in Xcode6.1 , I import the 'SDiPhoneVersion' to my project . When complie my project , I get an error with [SDiPhoneVersion deviceSize] method call:

Cannot initialize return object of type 'DeviceSize' with an rvalue of type 'int'
the method's return value can not be 0.

So in the defination of DeviceSize enum , I add a new enum value named Unknowninch = 0 :

typedef NS_ENUM(NSInteger, DeviceSize){
    Unknowninch = 0 ,
    iPhone35inch = 1,
    iPhone4inch = 2,
    iPhone47inch = 3,
   iPhone55inch = 4
 };

and in the deviceSize method call I change return 0 to return Unknowninch. With these my project run ok.

Why is there no iPad & Watch screen size?

Thanks for sharing this, I have used it in all my apps.

All along, I have a question. Since you named this library SDiOSVersion, I think that you should support all screen size, I don't understand why there is no iPad and Watch's screen size.

FYI: http://iosres.com/

minor note in docs.. re quotes.

A quick note for newcomers: you may have trouble with:

pod "SDVersion"

but you might have better luck with:

pod 'SDVersion'

Can't import SDVersion

Hi,

I use cocoapods to import this library and use use_frameworks! in my Podfile

I'm not able to do

import "SDVersion.h" in my bridging header nor am I able to import it directly in my class.

In my other project, I don't use use_frameworks! and I can import SDVersion in my bridging header.

Versions on Cocoapods/Github mismatch

Hi @sebyddd ,

I installed SDVersion through Cocoapods which version is v2.6.
But I noticed that it actually tagged as v2.5.2 on Github.
Could you check it?
Maybe you can later release the master version that supports iPhone SE.

Thanks.

SWIFT...

Hi,
Want to ask, can we have this fantastic Tool in swift 3?
It will be nice, if you have time to prepare a swift version of SDiPhoneVersion

Thanks in advance

George Gerardis

Update Podspec

Hello,

can you please update your podspec file? I just downloaded the source code using cocoapods, and it has a different version from the one on GitHub.

Thanks

Do not contains iPhone SE

I use cocoapods to import SDVersion 2.6, but I found it's still not support iPhone SE, and did not contains any code about iPhone SE. I don't know why, thank you!!

2.3 iOS pod broken

From the podspec:

  s.ios.source_files = "SDVersion/SDiOSVersion/*.{h,m}"

but your directory is still called SDiPhoneVersion, which means we don't have the iOS files in the pod:

screen shot 2015-08-27 at 11 05 43

I didn't want to do a PR since I don't know which name you want to keep.

How to detected iPhone5 or iPhone 5C?

I found iPhone5 and iPhone 5C are the same DeviceVersion NSInteger.
Your code:

typedef NS_ENUM(NSInteger, DeviceVersion){
iPhone4 = 3,
iPhone4S = 4,
iPhone5 = 5,
iPhone5C = 5,
iPhone5S = 6,
iPhone6 = 7,
iPhone6Plus = 8,

How can my app know user's device is iPhone 5C?

Get iPad screen size

It would be very helpful if I could target iPad screen size and not just iPhone.

Screen size for iPads

Hi,
Why we can not find screen size for iPad?
Can you fix it please?

Thanks very much

George Gerardis

Typo in the readme

Instead of:

      // Get device name
      NSLog(@"%@", stringFromDeviceVersion([SDVersion deviceName]));
      /* e.g: Outputs 'iPhone 6 Plus' */

I believe you meant to write:

      // Get device name
      NSLog(@"%@", stringFromDeviceVersion([SDVersion deviceVersion]));
      /* e.g: Outputs 'iPhone 6 Plus' */

DeviceSize returns UnknownSize with landscape left screen

I am coding with Swift language and I have notice when I rotate the iOS simulator for any iPhone model SDiPhoneVersion.deviceSize() returns UnknownSize. That only happen when I rotate to landscape left. I have tried my code with one physical iPhone and I have obtained the same mistake

[SDiPhoneVersion deviceSize] method's compatibility error above IOS8.0

According to the reference of the property [UIScreen mainScreen].bounds in ios8.0:

Discussion

This rectangle is specified in the current coordinate space, which takes into account any interface rotations in effect for the device. Therefore, the value of this property may change when the device rotates between portrait and landscape orientations.

so the method call [SDiPhoneVersion deviceSize] is error above IOS8.0.In this method , to get the correct value of the screenHeight, code snippet should be added :

//
// After IOS8.0 [UIScreen mainScreen].bounds takes into account any interface rotations in effect for the device,
// so the value of this property will change when the device rotate bewteen portrait and landscape.
//
if(iOSVersionGreaterThanOrEqualTo(@"8.0") && isLandscape){
    screenHeight = [UIScreen mainScreen].bounds.size.width;
}

Can't use DeviceSize enum from Swift 2.2, Xcode 7.3

Hi, @sebyddd
After I upgrade my Xcode to 7.3, I see this new error which was fine on Xcode 7.2.1.

When I try to use DeviceSize enum, it gives me build error.
....
let screen47Value = SDiOSVersion.DeviceSize.Screen4Dot7inch.rawValue)
-> Type of 'SDiOSVersion' has no member 'DeviceSize'
....

Do you have any workaround for this issue?
Thanks.

3.3 causes warning because of availability

Availability is meant to annotate a method is available since certain version or deprecate since certain version.
If anyone want to annotate a device's availability, they should define their own method or macro, otherwise compile the project will cause warnings.

Missing some code

Hi, @sebyddd,
I found a problem, when I use SDVersion v3.0.1 via CocoaPods, it's missing some code like the following in SDiOSVersion.h. My CocoaPods version is 1.0.0.

#define stringFromDeviceVersion(v) [@{@(3):@"iPhone 4", @(4):@"iPhone 4S", @(5):@"iPhone 5", @(6):@"iPhone 5C", @(7):@"iPhone 5S", @(8):@"iPhone 6", @(9): @"iPhone 6 Plus", @(10):@"iPhone 6S", @(11): @"iPhone 6S Plus", @(12):@"iPad 1", @(13):@"iPad 2", @(14):@"iPad Mini", @(15):@"iPad 3", @(16):@"iPad 4", @(17):@"iPad Air", @(18):@"iPad Mini 2", @(19):@"iPad Air 2", @(20):@"iPad Mini 3", @(21):@"iPad Mini 4", @(22):@"iPad Pro", @(23):@"iPod Touch 1st Gen", @(24):@"iPod Touch 2nd Gen", @(25):@"iPod Touch 3rd Gen", @(26):@"iPod Touch 4th Gen", @(27):@"iPod Touch 5th Gen", @(28):@"iPod Touch 6th Gen", @(0):@"Simulator"} objectForKey:[NSNumber numberWithInteger:v]]
#define stringFromDeviceSize(v) [@{@(0):@"Unknown Size", @(1):@"3.5 inch", @(2):@"4 inch", @(3):@"4.7 inch", @(4):@"5.5 inch"} objectForKey:[NSNumber numberWithInteger:v]]

I don't know why, hope to help me, thank you!

iOS: unknown device returns 0

SDiOSVersion.deviceVersion:101 objectForKey returns nil, then integerValue converts that into a 0
Unfortunately that's the same code as "Simulator". Could we have a code for Unknown?

You have iPhone 6S and 6S Plus platform strings mixed up.

For iPhone 6Plus it is 7,1 and iPhone 6 it is 7,2
BUT for iPhone 6SPlus it is 8,2 and iPhone 6S it is 8,1.

I tested this out on my 6 and 6S to validate. Apple slightly tweaked their naming. Hope this helps you fix your code.

CHANGE FROM:
@"iPhone8,2" :[NSNumber numberWithInteger:iPhone6S],
@"iPhone8,1" :[NSNumber numberWithInteger:iPhone6SPlus],

TO:
@"iPhone8,1" :[NSNumber numberWithInteger:iPhone6S],
@"iPhone8,2" :[NSNumber numberWithInteger:iPhone6SPlus],

ios 8 device size UIDeviceOrientationPortraitUpsideDown error

on ios 8 returning UnknownSize when the orientation is UIDeviceOrientationPortraitUpsideDown.

if (orientation == UIDeviceOrientationPortrait)
screenHeight = [[UIScreen mainScreen] bounds].size.height;
else if((orientation == UIDeviceOrientationLandscapeRight) || (orientation == UIInterfaceOrientationLandscapeLeft))
screenHeight = [[UIScreen mainScreen] bounds].size.width;

UIDeviceOrientationPortraitUpsideDown is missing on the if.

OSX Compatibility

That would be great to have only one library which handle both platform directly.
I don't think that would be too much work, maybe juste the project name won't fit...

What do you think? I can work on a PR if you are ok with that.

How do I get the DeviceVersionName in swift

Hello @sebyddd

This issue is closed once in #47
Although, I have same problem for now and that closed issue looks not resolved yet.

The following is the interface looks from Swift generated by Xcode.
DeviceVersionNames is a tuple in Swift, so I can't get user friendly name from DeviceVersion.

Did you support usage from Swift? Let me know if you so, and write down usage to README.

Thanks.

import UIKit

//
//  SDiOSVersion.h
//  SDVersion
//
//  Copyright (c) 2016 Sebastian Dobrincu. All rights reserved.
//

public enum DeviceVersion : Int {
    
    case iPhone4
    case iPhone4S
    case iPhone5
    case iPhone5C
    case iPhone5S
    case iPhone6
    case iPhone6Plus
    case iPhone6S
    case iPhone6SPlus
    case iPhone7
    case iPhone7Plus
    case iPhoneSE
    
    case iPad1
    case iPad2
    case iPadMini
    case iPad3
    case iPad4
    case iPadAir
    case iPadMini2
    case iPadAir2
    case iPadMini3
    case iPadMini4
    case iPadPro12Dot9Inch
    case iPadPro9Dot7Inch
    
    case iPodTouch1Gen
    case iPodTouch2Gen
    case iPodTouch3Gen
    case iPodTouch4Gen
    case iPodTouch5Gen
    case iPodTouch6Gen
    
    case Simulator
}

public var DeviceVersionNames: (NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?, NSString?)

public enum DeviceSize : Int {
    
    case UnknownSize
    case Screen3Dot5inch
    case Screen4inch
    case Screen4Dot7inch
    case Screen5Dot5inch
}

public var DeviceSizeNames: (NSString?, NSString?, NSString?, NSString?, NSString?)

public class SDiOSVersion : NSObject {
    
    public class func deviceVersion() -> DeviceVersion
    public class func resolutionSize() -> DeviceSize
    public class func deviceSize() -> DeviceSize
    public class func deviceName() -> String!
    public class func isZoomed() -> Bool
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.