iphone-sdk-3.0

How to make a Global Array?

旧街凉风 提交于 2019-12-04 07:10:57
So, I read this post , and it's pretty much exactly what I was looking for. However... it doesn't work. I guess I'm not going to go with the singleton object, but rather making the array in either a Global.h file, or insert it into the _Prefix file. Both times I do that though, I get the error: Expected specifier-qualifier-list before 'static' and it doesn't work. So... I'm not sure how to get it to work, I can remove extern and it works, but I feel like I need that to make it a constant. The end goal is to have this Mutable Array be accessible from any object or any file in my project. Help

Saving images to a given location

泄露秘密 提交于 2019-12-04 06:26:06
问题 I want to take screenshots of the iPhone app view and save the images to a given location. My code below saves the images to the photo library, but I want to save it to some other given location. Is it possible to do so? Please help me up. My code is here: UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

Convert NSString to ASCII Binary Equivilent (and then back to an NSString again)

对着背影说爱祢 提交于 2019-12-04 05:29:23
问题 I'm having some problems with this. I want to take an NSString and convert it to an integer array of only 0,1 values that would represent the binary equivalent of an ascii string. So for example say I have the following NSString *string = @"A"; // Decimal value 65 I want to end up with the array int binary[8] = {0,1,0,0,0,0,0,1}; then given that I have the binary integer array, how do I go back to an NSString? I know that NSString stores characters as multiple bytes but I only want to use

Limiting pasted string length in UITextView or UITextField

别说谁变了你拦得住时间么 提交于 2019-12-04 04:47:00
The problem of limiting strings that are directly entered into a UITextView or UITextField has been addressed on SO before: iPhone SDK: Set Max Character length TextField iPhone sdk 3.0 issue However now with OS 3.0 copy-and-paste becomes an issue, as the solutions in the above SO questions don’t prevent pasting additional characters (i.e. you cannot type more than 10 characters into a field that is configured with the above solutions but you can easily paste 100 characters into the same field). Is there a means of preventing directly entered string and pasted string overflow? I was able to

How to create a NSMutable Array which can access from different view controllers

╄→гoц情女王★ 提交于 2019-12-04 04:28:35
问题 Im quite new to iphone development, I want to create a mutable array which can access and populate from different view controllers. How can I do it? If you can please give me a sample code 回答1: In most cases its not needed nor helpfull to use global variables. If you have to use them the easiest way is to put the array in your AppDelegate. You can access the Array (named array in AppDelegate here) with : YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication]

Objective-C error: Property 'active' is a scalar type on class 'Routine'. Cannot generate a getter method for it

我怕爱的太早我们不能终老 提交于 2019-12-04 04:24:33
I'm getting the above error when the following runs in the iphone simulator (3.0 OS): @interface Routine : NSManagedObject { } @property (nonatomic) BOOL active; @implementation Routine @dynamic active @end As you can see, I'm subclassing NSManagedObject because I'm using Core Data. In my data model, "active" is an option attribute of type Boolean. What am I doing wrong here? Thanks! Louis Gerbarg Everything that comes out of CD is an object, not a scaler. So, changer your code to: @interface Routine : NSManagedObject { } @property (nonatomic) NSNumber * active; @implementation Routine

How do I detect whenever two UIImageView overlap?

痞子三分冷 提交于 2019-12-04 03:19:28
问题 I have two UIImageViews, one of them is moving from left to right, the other one is touch draggable. iI want NSLog to show up a message on console whenever imagetwo overlaps imageone. How Do I do this? 回答1: You can use the CGRectIntersectsRect function to easily test rectangle intersection, provided the UIImageViews share the same superview (more exactly, have the same coordinate space). Likely you will need to add code like the following: -(void) touchesEnded:(NSSet *) touches { if

How to make a UIView that can cover the navigation bar?

风格不统一 提交于 2019-12-04 00:07:39
I want to show the UIView in full screen, but show the status bar, other things, like the navigation bar need to cover by the UIView . How can I do that ? dannywartnaby Struggling a little to fully understand the question, but I think you're asking how you can display a UIView above another view (so that the view with the navigation controls is completely hidden by the second view)? UIViewController has: - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated It would be wise to have your second view managed by a UIViewController , too. For the sake

A thin whiteline is been added when resize the image

≡放荡痞女 提交于 2019-12-03 23:04:49
When we resizing the image (after downloading and before storing that in document directory), by the following code: -(UIImage *)resizeImage:(UIImage *)image withSize:(CGSize)newSize { float actualHeight = image.size.height; float actualWidth = image.size.width; float imgRatio = actualWidth/actualHeight; float maxRatio = newSize.width/newSize.height; if(imgRatio!=maxRatio){ if(imgRatio < maxRatio){ imgRatio = newSize.width / actualHeight; actualWidth = imgRatio * actualWidth; actualHeight = newSize.width; } else{ imgRatio = newSize.height / actualWidth; actualHeight = imgRatio * actualHeight;

UIModalTransitionStyle horizontal movement

可紊 提交于 2019-12-03 22:50:30
问题 The UIModalTransitionStyle is either Vertical, Flip or Dissolve. I would like it to be right to left or left to right, like if you click on a disclosure button on a MapKit callout or in a navigation based app. 回答1: This is impossible as transition for a modal viewController, but you could use a CATransition with a type of kCATransitionMoveIn or kCATransitionPush and a subtype of kCATransitionFromRight CATransition* trans = [CATransition animation]; trans.type = kCATransitionPush; trans