objective-c

Setting accessibility identifier programmatically on UIBarButtonItem

醉酒当歌 提交于 2021-02-18 03:49:55
问题 The accessibility identifier is a developer generated ID for GUI objects, which can be used for automation tests. A UIBarButtonItem does not implement UIAccessibilityIdentification . However is there a possibility that I can assign an accessibility identifier? 回答1: You could subclass UIBarButtonItem and implement the UIAccessibilityIdentification protocol in that subclass, lets's say BarButtonWithAccesibility . In BarButtonWithAccesibility.h : @interface BarButtonWithAccesibility :

How to Connect multiple peers on the iPhone Application over WiFi?

北战南征 提交于 2021-02-18 03:24:16
问题 I have an idea for an ios(iPhone) application to which requires connecting to several peers. I am basing my code on the WiTab (SampleCode-developer.apple.com) example. When my application started each peer creating separate Socket(CFSocket) and publishing through NSNetService Class.In particular instance NSNetServiceBrowser class find available peers. And display their name in TableView.When i select row in the table view the corresponding peer address resolved, a connection established and

How to Connect multiple peers on the iPhone Application over WiFi?

霸气de小男生 提交于 2021-02-18 03:22:38
问题 I have an idea for an ios(iPhone) application to which requires connecting to several peers. I am basing my code on the WiTab (SampleCode-developer.apple.com) example. When my application started each peer creating separate Socket(CFSocket) and publishing through NSNetService Class.In particular instance NSNetServiceBrowser class find available peers. And display their name in TableView.When i select row in the table view the corresponding peer address resolved, a connection established and

NSColor | Creating Color from RGB Values

ⅰ亾dé卋堺 提交于 2021-02-17 20:30:35
问题 In my application, i will get RGB Values as a unsigned character so it will not be more then 255, I am using NSColor API to create the color and will make use of it to draw the font and background color, this is the function that i have written +(NSColor *)getColorFromRGB:(unsigned char)r blue:(unsigned char)b green:(unsigned char)g { CGFloat rFloat = r/255.0; CGFloat gFloat = g/255.0; CGFloat bFloat = b/255.0; // return [NSColor colorWithCalibratedRed:((float)r/255.0) green:((float)g/255.0)

NSColor | Creating Color from RGB Values

纵然是瞬间 提交于 2021-02-17 20:28:20
问题 In my application, i will get RGB Values as a unsigned character so it will not be more then 255, I am using NSColor API to create the color and will make use of it to draw the font and background color, this is the function that i have written +(NSColor *)getColorFromRGB:(unsigned char)r blue:(unsigned char)b green:(unsigned char)g { CGFloat rFloat = r/255.0; CGFloat gFloat = g/255.0; CGFloat bFloat = b/255.0; // return [NSColor colorWithCalibratedRed:((float)r/255.0) green:((float)g/255.0)

UICollectionView Cell Shadow

孤者浪人 提交于 2021-02-17 19:47:10
问题 I am trying to add shadow to my custom UICollectionViewCell , This is the code I am using in my custom collection view cell class: self.layer.shadowOffset = CGSizeMake(1, 0); self.layer.shadowColor = [[UIColor blackColor] CGColor]; self.layer.shadowRadius = 5; self.layer.shadowOpacity = .25; This is giving shadow to the components of the collection view cell. 回答1: Don't forget to add these 2 lines self.clipsToBounds = false self.layer.masksToBounds = false 回答2: Swift 4.2 and xcode 10 here's

UICollectionView Cell Shadow

狂风中的少年 提交于 2021-02-17 19:45:08
问题 I am trying to add shadow to my custom UICollectionViewCell , This is the code I am using in my custom collection view cell class: self.layer.shadowOffset = CGSizeMake(1, 0); self.layer.shadowColor = [[UIColor blackColor] CGColor]; self.layer.shadowRadius = 5; self.layer.shadowOpacity = .25; This is giving shadow to the components of the collection view cell. 回答1: Don't forget to add these 2 lines self.clipsToBounds = false self.layer.masksToBounds = false 回答2: Swift 4.2 and xcode 10 here's

Concatenate and stringize macro values for #include

旧街凉风 提交于 2021-02-17 06:22:07
问题 I'm trying to create a string from multiple macros/values for use in a #include . I'm doing this to clean up some code for an initial state in a simple state system. I have 2 default, redefinable macros (if not defined there's a default value) #define DEFAULT_STATE StateName // name of class #define DEFAULT_STATE_LOCATION states/ // location of header file from root The include directive is being used from a file 4 folders in from the root , so the include should look like this #include "../.

What are all valid ways of writing closures that return nothing and accept no parameters in Objective-C and Swift?

。_饼干妹妹 提交于 2021-02-17 05:50:08
问题 I'm having trouble understanding closure syntax in Swift and Objective-C. Can someone tell me all possible ways in both languages to write a closure which accepts no arguments and returns nothing? 回答1: In Objective-C language void (^closureA)(void) = ^{ }; In Swift language let closureB: () -> () let closureC: () -> Void 回答2: Since you ask for all and since C is within Objective-C's reach and since you specify no parameters, this also gets the job done. void ( * f ) ( void ); // C function

How to ignore my app's window on screenshot? (Swift 2.0)

喜夏-厌秋 提交于 2021-02-17 04:49:22
问题 I wanted to get an image of the screen, ignoring my app's window. Found a code example in Objective-C and tried to convert it to Swift. Objective-C snipped: // Get onscreen windows CGWindowID windowIDToExcude = (CGWindowID)[myNSWindow windowNumber]; CFArrayRef onScreenWindows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); CFMutableArrayRef finalList = CFArrayCreateMutableCopy(NULL, 0, onScreenWindows); for (long i = CFArrayGetCount(finalList) - 1; i >= 0; i--) {