w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » OBJECTIVE C » Page 1
Size inner view in UIScrollView to the ScrollView's outer size
I'm assuming you are adding the constraints programmatically since you get that error, anyway the trick is to link the image's size to the scrollview frame size (not content size) [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[scrollView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(scrollView)]]; [self.view addConstraints:[NSLayoutConstraint const

Categories : Objective C

How to give Space between rows and columns of NSCollectionView?
If you are using storyboard to create the collection view update the Min Spacing and Section Inset like

Categories : Objective C

Layout issue with ios7 iphone5 screen but working fine in iphone5 and ios8
Yahoo.. I was able to resolve it. To resolve the issue, follow the below steps: Navigate to project settings Under "App Icons and Launch Images" click on "Use Asset Catalog" Select "Migrate" on the popup that appears. Its working fine for me.

Categories : Objective C

UITableView change color of multiple selection checkmarks
Note that in iOS 7, using [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; will not work as expected, because in iOS 7 this is now gray, even if you pass the constant above. See: https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/c/tdef/UITableViewCellSelectionStyle So use this to change color in the - (U

Categories : Objective C

Can this be shortened? font = font ? font : defaultFont;
There is a shortcut syntax ?: used like this: font = font ?: defaultFont; which is shorthand for font = font ? font : defaultFont; This is from a GCC extension, and also works by default with clang, so should just work for you.

Categories : Objective C

How when Button pressed twice the color should change
You can create a int property to check the state of the button and increment it. So, here is how my viewController.h looks like: #import <UIKit/UIKit.h> enum clickedTimes{ neverClicked, clickedOnce, clickedTwice }; @interface ViewController : UIViewController @property int cTimes; @property (weak, nonatomic) IBOutlet UIButton *myButton; - (IBAction)changeColour:(id)sender;

Categories : Objective C

IOS 8: doesn't sent emails
use this code, may help you - (IBAction) emailBtn_Click:(id)sender { if([self canDeviceSendEmail]) { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.modalPresentationStyle=UIModalPresentationFullScreen; picker.mailComposeDelegate = self; [picker setSubject:@"Report"]; [picker setTitle:@""]; NSString *emailBody = [NSString stringWit

Categories : Objective C

How to create a FullScreen NSWindow which should show the dock but hide menu bar?
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary]; [_window toggleFullScreen:self]; [NSMenu setMenuBarVisible:NO]; } Try above code.

Categories : Objective C

Convert Base64 GZipped string Objective-c or Swift
This answer here covers Base64. zlib is available directly as a shared library on Mac OS X and iOS. It can decompress gzip streams. Note that the first four bytes of your example have to be stripped before you get to the gzip stream. They appear to contain the size of the uncompressed data in little-endian form. (They are 08 00 00 00 in your example.)

Categories : Objective C

Change Windows root dynamically, Swift
Is the RevealViewController already presented? This is how I usually switch to a new root view controller: viewController.presentViewController(drawerController, animated: true) { let window = UIApplication.sharedApplication().delegate?.window?? if window?.rootViewController != drawerController { window?.rootViewController = drawerController } } where viewController is the o

Categories : Objective C

OS X: always run app with root privileges
The usual way to do this on Unix systems is to use setuid. Basically, you change the owner of your program to be root, and set the "set user or group ID on execution" bit (s): $ chown root:root myprogram $ chmod u+s myprogram Any time a user then executes your program, it will run as root. Note, though, that there are very good reasons for prompting for admin credentials. Using this mechanism

Categories : Objective C

Slow Swift Arrays and Strings performance
There are multiple reasons why the Swift code is slower than the Objective-C code. I made a very simple test case by comparing two fixed strings 100 times. Objective-C code: 0.026 seconds Swift code: 3.14 seconds The first reason is that a Swift Character represents an "extended grapheme cluster", which can contain several Unicode code points (e.g. "flags"). This makes the decomposition of a

Categories : Objective C

Change object on KVO path
It all comes down to what you mean by assigning or allocating another object to B. As far as I understand you have a variable named B that references the object you are observing. KVO works with objects, not variables so if you point your variable B to another object the KVO will remain in place and will not automatically extend to the other object. Hope this helps.

Categories : Objective C

Sort NSPredicate with in clausule with array's order
So if you want to fetch core data objects and link them up with an array of id's you should consider using the ever so powerful NSDictionary: So once you have fetched all your objects simply store those objects in a dictionary keyed by id: NSDictionary *managedObjectsKeyedByID = [NSDictionary dictionaryWithObjects:fetchedObjects forKeys:[fetchedObjects valueForKey:@"identifier"]]; Now you can

Categories : Objective C

Push Notification Not delivered in IOS8.1 but working fine in less then that
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } else { [[UIApplication sha

Categories : Objective C

UITextChecker: Way to Check If Word is Already Correct?
From Apple developer library, rangeOfMisspelledWordInString returns {NSNotFound, 0} if no misspelled word is found which is exactly what you are asking for. It is guessesForWordRange that will return an empty array if no correction is found. In short you should call guessesForWordRange only when there is a misspelled word range returned by rangeOfMisspelledWordInString.

Categories : Objective C

Use UIActionsheet when click in the table cell
Forget your method, try this: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *actionSheetTitle = @"Action Sheet Demo"; //Action Sheet Title NSString *destructiveTitle = @"Destructive Button"; //Action Sheet Button Titles NSString *other1 = @"Other Button 1"; NSString *other2 = @"Other Button 2"; NSString *other3 = @"Other

Categories : Objective C

Converting INT to Hex string to be sent over BLE
Here, what can inspire you: I made a category method of NSData (you may find this code elsewhere on SO, don't remember where exactly, it's not mine, there are a few questions about that in SO, but I think I mixed the various answers), adding this: +(NSData *)dataWithStringHex:(NSString *)string { NSString *cleanString; cleanString = [string stringByReplacingOccurrencesOfString:@"<" wi

Categories : Objective C

NSSplitViewController in OSX 10.10 using Xcode 6
If the delegate of a split view implements one of the following methods, it becomes incompatible with auto layout. splitView:constrainMinCoordinate:ofSubviewAt: splitView:constrainMaxCoordinate:ofSubviewAt: splitView:resizeSubviewsWithOldSize: splitView:shouldAdjustSizeOfSubview: https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/#10_8AutoLayout And because NSSpl

Categories : Objective C

Determine when a NSWindow is closing versus leaving full screen
Turns out I was getting the notification from a window that wasn't my NSWindowController's window! Printing out the notification that I was receiving we can see that I was getting the NSWindowWillCloseNotification call for a NSToolbarFullScreenWindow: NSConcreteNotification 0x6080002578b0 {name = NSWindowWillCloseNotification; object = <NSToolbarFullScreenWindow: 0x100d57f50>} I should ha

Categories : Objective C

Swift: Print(object) in console not showing variable properties like Objective-C for NSObjects
Correct way: po _myObject po - print object. You can read this

Categories : Objective C

How to display/handle a JavaScript alert in an OS X WebView?
In order to handle JavaScript alerts and confirmation dialog boxes, you need to specify the WebUIDelegate: @web_view = WebView.alloc.initWithFrame(NSMakeRect(0, 0, 1000, 500)) @web_view.setUIDelegate(self) ...and implement these methods: def webView(web_view, runJavaScriptAlertPanelWithMessage: message, initiatedByFrame: frame) alert = NSAlert.new alert.addButtonWithTitle("OK") alert.set

Categories : Objective C

Change height of an SKShapeNode
The frame of an SKShapeNode is read-only. If you would like to change the node's height, you can replace this CGRect temp = world.frame; temp.size.height = (world.frame.size.height / 1.2); world.frame = temp; with this world.yScale = 1.0 / 1.2;

Categories : Objective C

Cucumber Test with Frank on Yosemite result in Segementation Fault
Just want to re-iterate this question and ask for any help. I am seeing the same issue. I am also not clear on the steps to add accessibility and anything else under Yosemite. sh: line 1: 6180 Trace/BPT trap: 5 /Library/Ruby/Gems/2.0.0/gems/sim_launcher-0.4.13/lib/sim_launcher/../../native/ios-sim "showsdks" 2>&1 sh: line 1: 6184 Segmentation fault: 11 /Library/Ruby/Gems/2.0.0/gem

Categories : Objective C

objective-C: Why interface type can't be statically allocated?
In C++ you can't have polymorphic objects unless you have a pointer to that object. Objective-C doesn't let you open that can of worms. It's a dynamically typed language (with a lot of protection if you want) - and locking in your type at compile time goes against the philosophy of the language. NSString *s2 = [[NSString alloc] initWith ???]; consider that line. You're allocating a string ob

Categories : Objective C

UIView not animating constraint change
You want to change the properties of the UIView not the NSLayoutConstraint in the animation method. I.e. Change the layout constraint's constant before the UIView method and then change the UIView's frame property in the animation method. This way you won't need to call layoutIfNeeded.

Categories : Objective C

UIActionSheet button text not showing on iOS 8.x
UIActionSheet for iOS 8 so please refer this https://developer.apple.com/library/ios/documentation/Uikit/reference/UIActionSheet_Class/index.html

Categories : Objective C

IOS 7 - Unable to read/load an image
A few hundred bytes into the PNG file, it starts to embed 200kb of RDF data for no apparent reason (using Photoshop "Save..." instead of "Save for Web...", perhaps?): <?xpacket begin="Ôªø" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.5-c021 79.155772, 2014/01/13-19:44:00 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/2

Categories : Objective C

When Internet speed is low My Service taking long time get data, how to achieve timed out
Use NSMutableURLRequest like the following with timeoutInterval to set the request time out limit. NSString *urlString = @"your url string"; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; send request with: [NSURLConnection sendAsynchronousRequest:request

Categories : Objective C

iphone MKMapView 34000 annotation
There are various ways to achieve this. 1. Add only those annotations which can be viewed on the screen and add annotations dynamically when user scrolls on the map. 2. Now the second case what if user zooms out of the mapview. In that case you can create clusters instead of annotations for each point indicating the number of annotations under the cluster. I guess this tutorial might help you

Categories : Objective C

How to rotate a uilabel in iOS 8
I have found that in iOS 8 you need to adjust your constraints when you animate views. Set up an IBOutlet the appropriate NSLayoutConstraints and change their constants before you reposition the view.

Categories : Objective C

Navigate from a UITabBarController to another UITabBarController
That's now how tab bar controllers are supposed to work. They're meant to be the root view controller of your app and are not designed to be pushed onto a navigation stack. Before creating a tab bar interface, you need to decide how you intend to use a tab bar interface. Because it imposes an overarching organization on your data,you should use one only in these specific ways: Install it

Categories : Objective C

How to connect an iOS to Svn server from Xcode 5.1?
I got the solution for this using Below links which provides clear explanation of configuring svn with Xcode http://www.wikihow.com/Install-Subversion-on-Mac-OS-X

Categories : Objective C

afnetworking request parameter sequence
You can't do that using the request manager in the way you currently are. Instead, you would need to create the parameter list yourself, and then create a request from that. Then you could use AFN to handle the request transmission and response. Note that the server shouldn't require a specific order and that this should be changed if possible. Note also that the dictionary of parameters has no

Categories : Objective C

How to present UIView with triangle popup overlay?
Before iOS 8 there was nothing built into UIKit that does this for you. You have to draw the view yourself or use an image to create the triangle. The easiest way to achieve this is probably to make a full screen image with transparency and put it onto a transparent view that you display on top of the existing view to "present the view". If you only need to support iOS 8, you should be able to u

Categories : Objective C

Translating Objective C call back to Swift
Apple has updated most of their documentation to have both Swift and Objective-C versions of the API, so you can view the GKMatchmakerViewControllerDelegate methods there. This function would be: func matchmakerViewController(viewController: GKMatchmakerViewController!, didFailWithError error:NSError!) { viewController.dismissViewControllerAnimated(true, completion: nil) println("Error fi

Categories : Objective C

What does @property in a header file mean in Obj C?
The property syntax lets you declare a combination of a getter and a setter in a short syntax. In your code, the declaration creates four methods: -(int) width; -(void)setWidth:(int)val; -(int) height; -(void)setHeight:(int)val; There is probably an implementation, too, which ties these methods to their "backing variables" with names width and height defined above; there may also be a @synthesi

Categories : Objective C

Objective-C: Separate number right/left of decimal
One way: Use stringWithFormat to convert to string "5.11". Use componentsSeparatedByString to seperate into an array of "5" and "11". Combine with stringWithFormat.

Categories : Objective C

Accessing a view controller's delegate from a Category on that view controller
The delegate is on the tableView, not the tableViewController, hence the following is what's needed: UIView *firstHeader = [self.tableView.delegate tableView:self.tableView viewForHeaderInSection:0];

Categories : Objective C




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.