Search Results

Search found 4899 results on 196 pages for 'ios newbie'.

Page 64/196 | < Previous Page | 60 61 62 63 64 65 66 67 68 69 70 71  | Next Page >

  • Error With Sending mail (kSKPSMTPPartMessageKey is nil)

    - by user1553381
    I'm trying to send mail in iPhone using "SKPSMTPMessage" and I added the libraries, In my class I added the following code: - (IBAction)sendMail:(id)sender { // if there are a connection if ([theConnection isEqualToString:@"true"]) { if ([fromEmail.text isEqualToString:@""] || [toEmail.text isEqualToString:@""]) { UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ??? ????? ???? ????????" delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [warning show]; }else { SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init]; test_smtp_message.fromEmail = fromEmail.text; test_smtp_message.toEmail = toEmail.text; test_smtp_message.relayHost = @"smtp.gmail.com"; test_smtp_message.requiresAuth = YES; test_smtp_message.login = @"[email protected]"; test_smtp_message.pass = @"myPass"; test_smtp_message.wantsSecure = YES; NSString *subject= @"Suggest a book for you"; test_smtp_message.subject = [NSString stringWithFormat:@"%@ < %@ > ",fromEmail.text, subject]; test_smtp_message.delegate = self; NSMutableArray *parts_to_send = [NSMutableArray array]; NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:plain_text_part]; // to send attachment NSString *image_path = [[NSBundle mainBundle] pathForResource:BookCover ofType:@"jpg"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @"inline;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey, @"base64",kSKPSMTPPartContentTransferEncodingKey, @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil]; [parts_to_send addObject:image_part]; test_smtp_message.parts = parts_to_send; Spinner.hidden = NO; [Spinner startAnimating]; ProgressBar.hidden = NO; HighestState = 0; [test_smtp_message send]; } }else { UIAlertView *alertNoconnection = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ???? ???? " delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [alertNoconnection show]; } } but when I tried to send it gives me the following Exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString appendString:]: nil argument' and it highlighted this line in SKPSMTPMessage.m [message appendString:[part objectForKey:kSKPSMTPPartMessageKey]]; and I Can't understand what is nil exactly Can Anyone help me in this issue? Thanks in Advance.

    Read the article

  • How to Add "Write a Review" / "Rate Us" Feature to My App?

    - by Ohad Regev
    I wish to add some sort of a "Write a Review" or "Rate Us" feature to my app so my customers can easily rate and review my app. Best practice I can think of is to have some sort of pop-up or open a UIWebView within my app so the user is not kicked off of my app while opening the App Store application as done in: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myAppName"]]; Does anyone knows of a way to do that?

    Read the article

  • Can't unwrap Optional.None tableviewcell

    - by Mathew Padley
    I've a table view that has a custom table view cell in it. My problem is that when i try and assign a value to a variable in the custom table view cell I get the stated error. Now, I think its because the said variable is not initialised, but its got me completely stumped. This is the custom table cell: import Foundation import UIKit class LocationGeographyTableViewCell: UITableViewCell { //@IBOutlet var Map : MKMapView; @IBOutlet var AddressLine1 : UILabel; @IBOutlet var AddressLine2 : UILabel; @IBOutlet var County : UILabel; @IBOutlet var Postcode : UILabel; @IBOutlet var Telephone : UILabel; var location = VisitedLocation(); func Build(location:VisitedLocation) -> Void { self.location = location; AddressLine1.text = "test"; } } My cell for row at index path is: override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { var addressCell = tableView.dequeueReusableCellWithIdentifier("ContactDetail") as? LocationGeographyTableViewCell; if !addressCell { addressCell = LocationGeographyTableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "ContactDetail"); } addressCell!.Build(Location); return addressCell; } As I say I'm completely baffled, the Build function calls the correct function in the tableviewcell. Any help will be gratefully appreciated. Ta

    Read the article

  • how to make a tableview to be grouped style without indenting cells

    - by Ying
    Hi, I want a tableview without floating headers and footers, but in the UITableViewStylePlain style. When I used a grouped style tableview, it draws this rounded rectangle around my cells, and it is annoying!! Is there a setting to turn this off? I have tried tableView.backgroundView = nil; tableView.separatorStyle = UITableViewCellSeparatorStyleNone; tableView.autoresizingMask = UIViewAutoresizingNone; All don't work. Does anyone have any idea how to do this? Thanks

    Read the article

  • How can I search for a string in a .txt file for NSScanner?

    - by pixelbitapps
    I currently have the following code to get a certain piece of code from the UIWebView: NSURL *requestTimetableURL = [NSURL URLWithString:@"http://www.dhsb.org/index.phtml?d=201435"]; NSLog(@"Loaded Timetable"); NSError *error; NSString *page = [NSString stringWithContentsOfURL:requestTimetableURL encoding:NSASCIIStringEncoding error:&error]; [webView loadHTMLString:page baseURL:requestTimetableURL]; NSString* Period1; NSScanner *htmlScanner = [NSScanner scannerWithString:page]; [htmlScanner scanUpToString:@"<P align=center><STRONG><FONT color=#c00000>" intoString:NULL]; [htmlScanner scanString:@"<P align=center><STRONG><FONT color=#c00000>" intoString:NULL]; [htmlScanner scanUpToString:@"</FONT>" intoString:&Period1]; How can I scan a .txt file (which contains the string like above) for the code? E.G. [htmlScanner scanUpToString:teststring intoString:NULL]; Thanks!

    Read the article

  • Singleton method not getting called in Cocos2d

    - by jini
    I am calling a Singleton method that does not get called when I try doing this. I get no errors or anything, just that I am unable to see the CCLOG message. Under what reasons would a compiler not give you error and not allow you to call a method? [[GameManager sharedGameManager] openSiteWithLinkType:kLinkTypeDeveloperSite]; The method is defined as follows: -(void)openSiteWithLinkType:(LinkTypes)linkTypeToOpen { CCLOG(@"WE ARE IN openSiteWithLinkType"); //I NEVER SEE THIS MESSAGE NSURL *urlToOpen = nil; if (linkTypeToOpen == kLinkTypeDeveloperSite) { urlToOpen = [NSURL URLWithString:@"http://somesite.com"]; } if (![[UIApplication sharedApplication]openURL:urlToOpen]) { CCLOG(@"%@%@",@"Failed to open url:",[urlToOpen description]); [self runSceneWithID:kMainMenuScene]; } } HERE IS THE CODE TO MY SINGLETON: #import "GameManager.h" #import "MainMenuScene.h" @implementation GameManager static GameManager* _sharedGameManager = nil; @synthesize isMusicON; @synthesize isSoundEffectsON; @synthesize hasPlayerDied; +(GameManager*) sharedGameManager { @synchronized([GameManager class]) { if (!_sharedGameManager) { [[self alloc] init]; return _sharedGameManager; } return nil; } } +(id)alloc { @synchronized ([GameManager class]) { NSAssert(_sharedGameManager == nil,@"Attempted to allocate a second instance of the Game Manager singleton"); _sharedGameManager = [super alloc]; return _sharedGameManager; } return nil; } -(id)init { self = [super init]; if (self != nil) { //Game Manager initialized CCLOG(@"Game Manager Singleton, init"); isMusicON = YES; isSoundEffectsON = YES; hasPlayerDied = NO; currentScene = kNoSceneUninitialized; } return self; } -(void) runSceneWithID:(SceneTypes)sceneID { SceneTypes oldScene = currentScene; currentScene = sceneID; id sceneToRun = nil; switch (sceneID) { case kMainMenuScene: sceneToRun = [MainMenuScene node]; break; default: CCLOG(@"Unknown Scene ID, cannot switch scenes"); return; break; } if (sceneToRun == nil) { //Revert back, since no new scene was found currentScene = oldScene; return; } //Menu Scenes have a value of < 100 if (sceneID < 100) { if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { CGSize screenSize = [CCDirector sharedDirector].winSizeInPixels; if (screenSize.width == 960.0f) { //iPhone 4 retina [sceneToRun setScaleX:0.9375f]; [sceneToRun setScaleY:0.8333f]; CCLOG(@"GM: Scaling for iPhone 4 (retina)"); } else { [sceneToRun setScaleX:0.4688f]; [sceneToRun setScaleY:0.4166f]; CCLOG(@"GM: Scaling for iPhone 3G or older (non-retina)"); } } } if ([[CCDirector sharedDirector] runningScene] == nil) { [[CCDirector sharedDirector] runWithScene:sceneToRun]; } else { [[CCDirector sharedDirector] replaceScene:sceneToRun]; } } -(void)openSiteWithLinkType:(LinkTypes)linkTypeToOpen { CCLOG(@"WE ARE IN openSiteWithLinkType"); NSURL *urlToOpen = nil; if (linkTypeToOpen == kLinkTypeDeveloperSite) { urlToOpen = [NSURL URLWithString:@"http://somesite.com"]; } if (![[UIApplication sharedApplication]openURL:urlToOpen]) { CCLOG(@"%@%@",@"Failed to open url:",[urlToOpen description]); [self runSceneWithID:kMainMenuScene]; } } -(void) test { CCLOG(@"this is test"); } @end

    Read the article

  • UIPickerView and empty core data array

    - by Mark
    I have a viewcontroller showing items from a core data entity. I also have a tableview listing records from the same entity. The table is editable, and the user could remove all the records. When this happens, the view controller holding the pickerview bombs because it's looking for records in an empty array. How to prevent this? I'm assuming I need to do something different at objectAtIndex:row... # pragma mark PickerView Section - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; // returns the number of columns to display. } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [profiles count]; // returns the number of rows } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { // Display the profiles we've fetched on the picker Profiles *prof = [profiles objectAtIndex:row]; return prof.profilename; } //If the user chooses from the pickerview - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { selectedProfile = [[profiles objectAtIndex:row]valueForKey:@"profilename"]; }

    Read the article

  • json array string covvertion to nsmutable array

    - by sudheer
    I am getting Json response from server. type = 2; "daysofWeek" = "(\n Mon,\n Tue\n)"; serviceType = 2; startDate = "2013-10-28"; In above format daysofWeek is Array string. I am trying to convert into NAMutableArray as NSString *weekDaysStr=[valueDict objectForKey:@"recrWeek_daysofWeek"]; NSMutableArray *weekDays=[[NSMutableArray alloc] initWithArray:[weekDaysStr componentsSeparatedByString:@","]]; But when i log this array i shownig as ("\n Mon", "\n Tue\n" ) How to remove those extra words from array. I have check each values to week day. NSString *day=@"Mon"; if([day isEQualToString:[weekDays objectAtIndex:0]){ } At that time its giving false condtion.Help me on this problem

    Read the article

  • addsubview animation works only first time

    - by Priya
    I am trying add subview with animation effect using the code which work fine for the first time below. CATransition *transition = [CATransition animation]; transition.duration = 1.0; transition.type = kCATransitionMoveIn; transition.subtype = kCATransitionFromRight; [newView.layer removeAllAnimations] [newView.layer addAnimation:transition forKey:nil]; [self.masterview addSubview:newView]; There is a back button in newView which removes the View from the superview. [newView removeFromSuperview]; Now when I try adding newView as subview again using the above code,its first adds the view as a subview(without animation) and again with animation.

    Read the article

  • drawRect gets called on UIView subclass but not on UIViewController

    - by HotFudgeSunday
    My code is working so far but I had to create a Class for the UIView. This is a bit inconvenient because I need to interact with the ViewController too. BTW, I did try [self setNeedsDisplay] on the ViewDidLoad of the UIViewController subclass file but it didn't work. Here's the code, which works on UIView Subclass but doesn't get called on a UIViewController one: - (void)drawRect:(CGRect)rect { UIColor *currentColor = [UIColor redColor]; CGContextRef context = UIGraphicsGetCurrentContext(); someNum = 1; CGContextBeginPath(context); CGContextMoveToPoint(context, 30, 40); [self addDotImageX:30 andY:40]; CGContextSetLineWidth(context, 2); CGContextSetStrokeColorWithColor(context, currentColor.CGColor); CGContextStrokePath(context); } Any ideas on what to try? BTW, this is a TabBar App. I know those can somehow block the calls to drawRect. The Tabs where created programatically, not through a Nib. Eg: NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init]; UIViewController *vc; vc = [[Education alloc] init]; vc.title = @"Education"; [listOfViewControllers addObject:vc]; vc.tabBarItem.image = [UIImage imageNamed:@"info.png"]; [vc release]; I would appreciate any ideas. I've been through the answers on this site related to setNeedsDisplay not calling drawRect and haven't found an answer for my particular case. Thanks.

    Read the article

  • First and last UITableViewCell keep changing while scrolling.

    - by W Dyson
    I have a tableView with cells containing one UITextField as a subview for each cell. My problem is that when I scroll down, the text in the first cell is duplicated in the last cell. I can't for the life if me figure out why. I have tried loading the cells from different nibs, having the textFields as ivars. The UITextFields don't seem to be the problem, I'm thinking it has something to do with the tableView reusing the cells. The textFields all have a data source that keeps track of the text within the textField and the text is reset each time the cell is shown. Any ideas? UPDATE: Thanks guys, here's a sample: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Section %i, Row %i", indexPath.section, indexPath.row); static NSString *JournalCellIdentifier = @"JournalCellIdentifier"; UITableViewCell *cell = (UITableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:JournalCellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:JournalCellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.accessoryType = UITableViewCellAccessoryNone; } if (indexPath.section == 0) { UITextField *textField = (UITextField *)[self.authorCell viewWithTag:1]; [cell addSubview:textField]; self.authorTextField = textField; self.authorTextField.text = [self.textFieldDictionary objectForKey:@"author"]; NSLog(@"Reading Author:%@", [self.textFieldDictionary objectForKey:@"author"]); } else if (indexPath.section == 1) { UITextField *textField = (UITextField *)[self.yearCell viewWithTag:1]; [cell addSubview:textField]; self.yearTextField = textField; self.yearTextField.text = [self.textFieldDictionary objectForKey:@"year"]; NSLog(@"Reading Year:%@", [self.textFieldDictionary objectForKey:@"year"]); } else if (indexPath.section == 2) { UITextField *textField = (UITextField *)[self.volumeCell viewWithTag:1]; [cell addSubview:textField]; self.volumeTextField = textField; self.volumeTextField.text = [self.textFieldDictionary objectForKey:@"volume"]; NSLog(@"Reading Volume:%@", [self.textFieldDictionary objectForKey:@"volume"]); } return cell; }

    Read the article

  • Prevent delegate method from being called too often

    - by Lord Zsolt
    How would you add a delay between certain method being called? This is my code that I want to only trigger 30 times per second: - (void) scrollViewDidScroll: (UIScrollView*)scrollView { [self performSelector:@selector(needsDisplay) withObject:nil afterDelay:0.033]; } - (void) needsDisplay { [captureView setNeedsDisplay]; } If I leave it like this, it only gets called after the user stopped scrolling. What I want to do is call the method when the user is scrolling, but with a delay of 33 milliseconds between each call.

    Read the article

  • Reload table view in real time

    - by Lucas Vallim da Costa
    The app receives a UILocalNotification, but if the user is at the UITableViewController at the fire time, the table view (containing the scheduled notifications) does not reload. The user has to get out of that view and load the view again so that the cells are loaded and, as the notification was already fired, it will not be displayed on any cell of that table view. Problem is: If the user touches the specific tableView cell that contained the notification that just fired, the app crashes, cause the notification is not there anymore. I've implemented the - (void)reloadData in every place possible, and it still doesn't load in real time. What would be a better solution for this? Other detail, how can I push a specific view after the notification is displayed (when the user slides the app icon when the phone is locked)? Any help will be truly appreciated, since theres are the last details remaining to publish my first App.

    Read the article

  • Dynamic title like in the Notes app

    - by Fran
    Hi, when the user enters text in a uitextview I would that the title of the navigation bar changed dynamically like it happens in the Notes app. How can I achieve this? I think a label is used, don't I? Thanks Fran EDIT: I know how change the title of a navigation bar, but how do this in a such way that the textview is tied to the title, so while user enters the first line of text in the same moment the title changes (letter by letter)?

    Read the article

  • Callback from static library

    - by MortenHN
    I think this should be simple, but im having a real hard time finding information about this topic. I have made a static library and have no problem getting the basics to work. But im having a hard time figuring out how to make a call back from the static library to the main APP. I would like my static library to only use one header as front, this header should contain functions like: requestImage:(NSString *)path; requestLikstOfSomething:(NSSting *)guid; and so on.. These functions should do the necessary work and start a async NSURLConnection, and call back to the main application when the call have finished. How do you guys do this, what are the best ways to callback from a static library when a async method is finished? should i do this with delegates (is this possible), notifications, key/value observers. I really want to know how you guys have solved this, and what you regard as the best practices. Im going to have 20-25 different calls so i want the static library header file to be as simple as possible preferable only with a list of the 20-25 functions. UPDATE: My question is not how to use delegate pattern, but witch way is the best to do callbacks from static librarys. I would like to use delegates but i dont want to have 20-25 protocol declarations in the public header file. I would prefer to have only one function for each request. Thanks in advance. Best regards Morten

    Read the article

  • CoreMidi _MIDINetworkNotificationContactsDidChange symbol not found

    - by Domestic Cat
    I'm getting the following error after a crash in an iPad app that uses CoreMIDI (The * are to blank out the app name): Dyld Error Message: Symbol not found: _MIDINetworkNotificationContactsDidChange Referenced from: /var/mobile/Applications/8F08B78E-929D-4C5A-9F02-08FD5743C17F/***.app/*** Expected in: /System/Library/Frameworks/CoreMIDI.framework/CoreMIDI in /var/mobile/Applications/8F08B78E-929D-4C5A-9F02-08FD5743C17F/***.app/*** Dyld Version: 179.4 When the app launches, I listen for MIDI Network Sessions using [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionDidChange:) name:MIDINetworkNotificationSessionDidChange object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionDidChange:) name:MIDINetworkNotificationContactsDidChange object:nil]; Which seems to be what is causing the crash. This is after I call session = [MIDINetworkSession defaultSession]; session.enabled = YES; session.connectionPolicy = MIDINetworkConnectionPolicy_Anyone; MIDIClientCreate(CFSTR("MidiManager"), midiNotifyProc, (void*)self, &midiClientRef); This kind of looks like CoreMIDI library has not been included in the build. Problem is, it IS included in the build as a required framework. (And the deployment target is set to 4.2). I can run the build fine on my iPad and have been testing extensively with other users' iPads also with no problems whatsoever. Also, this is an update to an existing app that has had several updates already with no problems. I just double checked my deployment build and the framework is definitely included, and I just installed that build onto my iPad (with a different provisioning profile from the store) and it works fine also. What could be happening? Could it be that Xcode just did a bad build for the one I sent to Apple, or am I missing something obvious? Could I change the MIDINetworkNotificationSessionDidChange notification symbol to a literal string (@"MIDINetworkNotificationSessionDidChange") to fix things for the mean time? Thanks for any help!

    Read the article

  • Breakpoint pointing out "objc_autoreleaseNoPool"

    - by Andrew
    So I'm debugging an app in preperation for its app so release, and I enabled a universal breakpoint for "All Exceptions". Since then, everytime I run the app, the console prints: Catchpoint 2 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved objc[11765]: Object 0x8f18ff0 of class __NSCFLocale autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug objc[11765]: Object 0x8f190a0 of class __NSCFNumber autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug objc[11765]: Object 0x8f1fef0 of class __NSCFLocale autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug Literally printed 3 times. I have no idea what this means but it looks bad. Any advice would be appreciated.

    Read the article

  • Putting data from SONObjectWithData to UITableView

    - by user2966615
    i am building a app in which i am getting data from a php file and already NSLoging it in xcode and it is showing data in this format: jsonObject=( ( 1, abc, "[email protected]", "501 B3 Town" ), ( 2, sam, "[email protected]", "502 B3 Town" ), ( 3, jhon, "[email protected]", "503 B Town" ) ) and here is my viewdidload - (void)viewDidLoad { [super viewDidLoad]; statuses=[[NSMutableArray alloc]init]; NSURL *myURL = [NSURL URLWithString:@"http://url/result.php"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { NSLog(@"Finished with status code: %i", [(NSHTTPURLResponse *)response statusCode]); id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]; NSLog(@"jsonObject=%@",jsonObject); statuses = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; }]; } now i want to display all records in uitableview. can anyone tell me how can i do that. Thanks

    Read the article

  • CGAffineTransformMakeRotation goes the other way after 180 degrees (-3.14)

    - by TheKillerDev
    So, i am trying to do a very simple disc rotation (2d), according to the user touch on it, just like a DJ or something. It is working, but there is a problem, after certain amount of rotation, it starts going backwards, this amount is after 180 degrees or as i saw in while logging the angle, -3.14 (pi). I was wondering, how can i achieve a infinite loop, i mean, the user can keep rotating and rotating to any side, just sliding his finger? Also a second question is, is there any way to speed up the rotation? Here is my code right now: #import <UIKit/UIKit.h> @interface Draggable : UIImageView { CGPoint firstLoc; UILabel * fred; double angle; } @property (assign) CGPoint firstLoc; @property (retain) UILabel * fred; @end @implementation Draggable @synthesize fred, firstLoc; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; angle = 0; if (self) { // Initialization code } return self; } -(void)handleObject:(NSSet *)touches withEvent:(UIEvent *)event isLast:(BOOL)lst { UITouch *touch =[[[event allTouches] allObjects] lastObject]; CGPoint curLoc = [touch locationInView:self]; float fromAngle = atan2( firstLoc.y-self.center.y, firstLoc.x-self.center.x ); float toAngle = atan2( curLoc.y-(self.center.y+10), curLoc.x-(self.center.x+10)); float newAngle = angle + (toAngle - fromAngle); NSLog(@"%f",newAngle); CGAffineTransform cgaRotate = CGAffineTransformMakeRotation(newAngle); self.transform = cgaRotate; if (lst) angle = newAngle; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch =[[[event allTouches] allObjects] lastObject]; firstLoc = [touch locationInView:self]; }; -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self handleObject:touches withEvent:event isLast:NO]; }; -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self handleObject:touches withEvent:event isLast:YES]; } @end And in the ViewController: UIImage *tmpImage = [UIImage imageNamed:@"theDisc.png"]; CGRect cellRectangle; cellRectangle = CGRectMake(-1,self.view.frame.size.height,tmpImage.size.width ,tmpImage.size.height ); dragger = [[Draggable alloc] initWithFrame:cellRectangle]; [dragger setImage:tmpImage]; [dragger setUserInteractionEnabled:YES]; dragger.layer.anchorPoint = CGPointMake(.5,.5); [self.view addSubview:dragger]; I am open to new/cleaner/more correct ways of doing this too. Thanks in advance.

    Read the article

  • how to create static line in coreplot

    - by Rémi Bédard-Couture
    I am trying to make my control lines static so instead of being displayed as part of the graph(the control lines are moving with the graph), they would be displayed like an axis the app can only scroll horizontally i'm talking about the two red line and the green line(which i put over the x axis) this is how i do my lines: // Center line CPTScatterPlot *centerLinePlot = [[CPTScatterPlot alloc] init]; centerLinePlot.identifier = kCenterLine; CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; lineStyle.lineWidth = 2.0; lineStyle.lineColor = [CPTColor greenColor]; centerLinePlot.dataLineStyle = lineStyle; centerLinePlot.dataSource = self; [graph addPlot:centerLinePlot]; but maybe it has something to do with the displayed range: ////////ajuste la portion a voir if(data.Resultats.count>10) { plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(data.Resultats.count - 10) length:CPTDecimalFromDouble(10)]; } plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(RangeMin) length:CPTDecimalFromDouble(RangeMax-RangeMin)]; // Adjust visible ranges so plot symbols along the edges are not clipped CPTMutablePlotRange *xRange = [plotSpace.xRange mutableCopy]; CPTMutablePlotRange *yRange = [plotSpace.yRange mutableCopy]; //place l'axe x sur la ligne de controle pour voir les WorkOrders x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(center); //x.orthogonalCoordinateDecimal = yRange.location; //y.orthogonalCoordinateDecimal = xRange.location; //x.visibleRange = xRange; //y.visibleRange = yRange; //x.gridLinesRange = yRange; //y.gridLinesRange = xRange; [xRange expandRangeByFactor:CPTDecimalFromDouble(1.15)];//1.05 [yRange expandRangeByFactor:CPTDecimalFromDouble(1.15)]; plotSpace.xRange = xRange; plotSpace.yRange = yRange;

    Read the article

  • Search pattern in string using regex in obj-c

    - by manileo86
    I'm working on a string pattern match algorithm. I use NSRegularExpression for finding the matches. For ex: I've to find all words starting with '#' in a string.. Currently I use the following regex function: static NSRegularExpression *_searchTagRegularExpression; static inline NSRegularExpression * SearchTagRegularExpression() { if (!_searchTagRegularExpression) { _searchTagRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(?<!\\w)#([\\w\\._-]+)? options:NSRegularExpressionCaseInsensitive error:nil]; } return _searchTagRegularExpression; } and I use it as below: NSRegularExpression *regexp = SearchTagRegularExpression(); [regexp enumerateMatchesInString:searchString options:0 range:stringRange usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { // comes here for every match with range }]; This works properly. But i just want to know if this is the best way. suggest if there's any better alternative...

    Read the article

  • Animating the drawing of a line

    - by jkigel
    I'm trying to animate the drawing of a line by the following way: .h CAShapeLayer *rootLayer; CAShapeLayer *lineLayer; CGMutablePathRef path; .m path = CGPathCreateMutable(); CGPathMoveToPoint(path, nil, self.frame.size.width/2-100, 260); CGPathAddLineToPoint(path, nil, self.frame.size.width/2+100.0, 260); CGPathCloseSubpath(path); self.rootLayer = [CALayer layer]; rootLayer.frame = self.bounds; [self.layer addSublayer:rootLayer]; self.lineLayer = [CAShapeLayer layer]; [lineLayer setPath:path]; [lineLayer setFillColor:[UIColor redColor].CGColor]; [lineLayer setStrokeColor:[UIColor blueColor].CGColor]; [lineLayer setLineWidth:1.5]; [lineLayer setFillRule:kCAFillRuleNonZero]; [rootLayer addSublayer:lineLayer]; [self performSelector:@selector(startTotalLine) withObject:nil afterDelay:1.5]; - (void)startTotalLine { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"animatePath"]; [animation setDuration:3.5]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [animation setAutoreverses:NO]; [animation setFromValue:(id)path]; [animation setToValue:(id)path]; [lineLayer addAnimation:animation forKey:@"animatePath"]; } The line had drawn before the startTotalLine method is invoked. Also, the startTotalLine method doesn't affect the line. I want it to animate the the line drawing from right to left

    Read the article

  • Issues using UITapGestureRecognizers in Interface Builder

    - by 5StringRyan
    I'm attempting to use the UITapGestureRecognizer object that can be found in Interface Builder. I've dragged a single "UITapGestureRecognizer" from the object library to a single view xib. I then create an IBAction method from this tap gesture, for a simple test, I'm just printing an "NSLog" message to the console once there is a tap on the view. I've run this, and the tap method isn't being called. I right click the view in IB and I noticed that there is a warning "!" on the view's "Outlook Collections" I see: Outlook Collections gestureRecognizers - Tap Gesture Recognizer (!) The warning states: UIView does not have an outlet collection named gestureRecognizers. What do I need to do to remedy this?

    Read the article

  • Should I create subclass NSManagedObject or not?

    - by TP
    Hi, I have spent a few days learning and writing NSCoding and finally got it working. However, it took very long to archive and unarchive the (quite complex) object graph, which is unacceptable. After searching the internet for some time, I think the better way is to use core data. Do you recommend that 1) I should rewrite all my classes as subclasses of NSManagedObject or 2) should I create an instance variable of NSManagedObject in each of my class so that any changes to the class also updates its core data representation? Doing either way will need significant changes to the exiting classes and I think I have to update lots of unit test cases as well if it changes the way the classes are initialized. What do you recommend? I really don't want to head to the wrong approach again... Thanks!

    Read the article

  • SQLite SQLite column can't be updated to any value but zero (real type)

    - by user1065320
    Hi I'm trying to create a three fields table (date,text,real), I can insert and update the first two fields but can't set or update the last one. createSQL = @"CREATE TABLE IF NOT EXISTS ACTIVITIES (MYDATE DATETIME PRIMARY KEY, ACTIVITY TEXT , LENGTH REAL);"; try to insert char *update = "INSERT OR REPLACE INTO ACTIVITIES (MYDATE, ACTIVITY , LENGTH) VALUES (?, ? ,?);"; sqlite3_stmt *stmt; if (sqlite3_prepare_v2(database, update , -1, &stmt, nil) == SQLITE_OK) { sqlite3_bind_double(stmt, 1, valueToWrite); sqlite3_bind_text(stmt, 2, [task UTF8String], -1, NULL); sqlite3_bind_double(stmt, 3, 1.5); } if (sqlite3_step(stmt) != SQLITE_DONE) { NSAssert1(0, @"Error updating table: %s", errorMsg); } sqlite3_finalize(stmt); sqlite3_close(database); The first two values are updated but the last one remains 0 even if I'm writing a value like 1.5 or put a double variable with a different value Thanks

    Read the article

< Previous Page | 60 61 62 63 64 65 66 67 68 69 70 71  | Next Page >