Search Results

Search found 102 results on 5 pages for 'ios5'.

Page 3/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • autorelease object not confirming protocol does not give any warning

    - by Sahil Wasan
    I have a class "ABC" and its method which returns non autoreleases object of that class. @interface ABC:NSObject +(ABC *)aClassMethodReturnsObjectWhichNotAutoreleased; @end @implementation ABC +(ABC *)aClassMethodReturnsObjectWhichNotAutoreleased{ ABC *a = [[ABC alloc]init]; return a; } @end If I have a protocol Foo. @Protocol Foo @required -(void)abc; @end My ABC class is "not" confirming Foo protocols. 1st call id<Foo> obj = [ABC aClassMethodReturnsObjectWhichNotAutoreleased]; //show warning It shows warning "Non Compatible pointers.." thats good.Abc did not confirm protocol Foo BUT 2nd call id<Foo> obj = [NSArray arrayWithObjects:@"abc",@"def",nil]; // It will "not" show warning as it will return autorelease object.NSArray don't confirm protocol Foo In first call compiler gives warning and in second call compiler is not giving any warning.I think that is because i am not returning autorelease object. Why is compiler not giving warning in 2nd call as NSArray is also not confirming FOO Thanks in advance

    Read the article

  • Timezoneoffset error when daylightsaving in effect in iOS

    - by Ranjit
    friends,I am getting a date based on the calculation I have done below NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *expectedDate = [gregorian dateByAddingComponents:components toDate:startDate options:0]; NSTimeInterval timeZoneOffset = -[[NSTimeZone systemTimeZone] secondsFromGMTForDate:expectedDate]; NSDate *localDate = [expectedDate dateByAddingTimeInterval:(timeZoneOffset)]; NSString *date = [dateFormatter stringFromDate:localDate]; But the date goes wrong when the daylightsaving is in effect,and also the timeZoneOffset changes when the daylightsaving is in effect, but I want the same date irrespective of whether the daylight saving is in effect or no.. So friends,how shall I handle this situation,please help. Regards Ranjit

    Read the article

  • Added a tableview in a viewcontroller. How do I load tableview cells

    - by user1509593
    I have a view controller In storyboard, added tableview to view controller. Created an IBOutlet for tableview to View controller's header file. The view controller's header file includes an resultsarray Changed the @interface to include delegates <\UITableViewDelegate, UITableViewDataSource View controller implementation file has mandatory tableview protocols (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath The view controller has search button in storyboard and IBAction in view controller header file. On click of search button, results are obtained. How do I load the array and redisplay tableview with results in search method. After I loaded the results in array, I tried [self viewdidload];, hoping the cells will be loaded. But didn't. I thought of calling [self.detailView cellForRowAtIndexPath:?indexpath], but dontknow what the value of index path is. Appreciate help from guru's to load the UItableviewcell Thanks

    Read the article

  • Check if iOS app is live in app store

    - by MSK
    Is it possible somehow to code like below in iOS app ? if(app is live in app store) { //Do something } else { //Do other thing } I wanted to avoid cases where our QE/Dev team is using app for testing. Is there a way I can detect how app code is signed (Developer/Adhoc/Distribution) to check ? Even if it is possible, it will not eliminate cases when Apple is using our app for testing as part of review. We recorded many downloads of our content by Apple before our app goes live in App store.

    Read the article

  • UITableView not getting populated with sqlite database column

    - by Ingila Ejaz
    Here's the code of a method I used to populate UITableView with the contents of a column in sqlite database. However, this is giving no errors at run-time but still does not give any data in UITableView. If anyone could help, it'll be highly appreciated. - (void)viewDidLoad{ [super viewDidLoad]; self.title = @"Strings List"; UITableViewCell *cell; NSString *docsDir; NSArray *dirPaths; sqlite3_stmt *statement; // Get the documents directory dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; // Build the path to the database file databasePath = [[NSString alloc]initWithString: [docsDir stringByAppendingPathComponent:@"strings.sqlite"]]; NSFileManager *filemgr = [NSFileManager defaultManager]; if ([filemgr fileExistsAtPath: databasePath ] == NO) { const char *dbpath = [databasePath UTF8String]; if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK) { NSString * query = @"SELECT string FROM strings"; const char * stmt = [query UTF8String]; if (sqlite3_prepare_v2(contactDB, stmt, -1,&statement, NULL)==SQLITE_OK){ if (sqlite3_step(statement) == SQLITE_ROW) { NSString *string = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(statement, 0)]; cell.textLabel.text = string; } } else NSLog(@"Failed"); sqlite3_finalize(statement); } sqlite3_close(contactDB); } }

    Read the article

  • Read Call History from iPhone on iOS 5 and above

    - by Sandeep Dhama
    I am developing an application and need to read the users call history from iPhone.I have go though all the forums and google it and found that we can get the records from teh callHistory sqlite database by "private/var/root/Library/CallHistory/call_history.db". But this path is not working from iOS 5 and above. Seems like apple has changed all their database path and structure so that no one can accees it. I have also seen some of the application on iTunes who are capable of getting the users call history like:-https://itunes.apple.com/us/app/callog/id327883585?mt=8 I have also check a mac desktop utility called "WonderShare Dr.Fone" which will fetch all the data from your iPhone like call history messages, notes , etc.How this utility is fetching the call history records and other details? If their is any API or private APIs by which i can get the callHistory data path please let me know.

    Read the article

  • Core Plot: x-axis labels not plotted when using scaleToFitPlots

    - by AlexR
    Problem: I can't get Core Plot (1.1) to plot automatic labels for my x-axis when using autoscaling ([plotSpace scaleToFitPlots:[graph allPlots]). What I have tried: I changed the values for the offsets and paddings, but this did not change the result. However, when turning autoscale off (not using [plotSpace scaleToFitPlots:[graph allPlots]]and setting the y scale automatically, the automatic labeling of the x-axis works. Question: Is there a bug in Core Plot or what did I do wrong? I would appreciate any help! Thank you! This is how I have set up my chart: CPTBarPlot *barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO]; barPlot.baseValue = CPTDecimalFromInt(0); barPlot.barOffset = CPTDecimalFromFloat(0.0f); // CPTDecimalFromFloat(0.5f); barPlot.barWidth = CPTDecimalFromFloat(0.4f); barPlot.barCornerRadius = 4; barPlot.labelOffset = 5; barPlot.dataSource = self; barPlot.delegate = self; graph = [[CPTXYGraph alloc]initWithFrame:self.view.bounds]; self.hostView.hostedGraph = graph; graph.paddingLeft = 40.0f; graph.paddingTop = 30.0f; graph.paddingRight = 30.0f; graph.paddingBottom = 50.0f; [graph addPlot:barPlot]; graph.plotAreaFrame.masksToBorder = NO; graph.plotAreaFrame.cornerRadius = 0.0f; graph.plotAreaFrame.borderLineStyle = borderLineStyle; double xAxisStart = 0; CPTXYAxisSet *xyAxisSet = (CPTXYAxisSet *)graph.axisSet; CPTXYAxis *xAxis = xyAxisSet.xAxis; CPTMutableLineStyle *lineStyle = [xAxis.axisLineStyle mutableCopy]; lineStyle.lineCap = kCGLineCapButt; xAxis.axisLineStyle = lineStyle; xAxis.majorTickLength = 10; xAxis.orthogonalCoordinateDecimal = CPTDecimalFromDouble(yAxisStart); xAxis.paddingBottom = 5; xyAxisSet.delegate = self; xAxis.delegate = self; xAxis.labelOffset = 0; xAxis.labelingPolicy = CPTAxisLabelingPolicyAutomatic; [plotSpace scaleToFitPlots:[graph allPlots]]; CPTMutablePlotRange *yRange = plotSpace.yRange.mutableCopy; [yRange expandRangeByFactor:CPTDecimalFromDouble(1.3)]; plotSpace.yRange = yRange; NSInteger xLength = CPTDecimalIntegerValue(plotSpace.xRange.length) + 1; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(xAxisStart) length:CPTDecimalFromDouble(xLength)] ;

    Read the article

  • App closes after facebook login in IOS 5

    - by Aromal Sasidharan
    I am using facebook sdk 3.1 framework for my application. The login process works successfully and returns to the app after facebook login both in simulator(iOS 6.0 and 5.0) and in iPad(iOS 6). But When the same is deployed in IPad with IOS 5, after login, it does not return back to my application and shows a blank white Screen or sometimes my application closes. I dont know what went wrong in iOS 5 and facebook sdk 3.1 framework, also i am not getting any logs to debug... Please help Iam using this code for login NSArray *permissions = [[NSArray alloc] initWithObjects: //@"user_likes", //@"read_stream", @"publish_stream", @"user_events", @"read_friendlists", @"user_birthday", @"email", nil]; [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES completionHandler: ^(FBSession *session, FBSessionState state, NSError *error) { NSLog(@"state %d", state); [self sessionStateChanged:session state:state error:error]; }];

    Read the article

  • Change UIView alpha value

    - by Ask
    I'm trying to create an UIView and change its alpha property to simulate backlight change. Here is my code if (TransparentView == nil) { TransparentView = [[UIView alloc] initWithFrame:self.view.bounds]; TransparentView.backgroundColor = [UIColor whiteColor]; self.view = TransparentView; } start=start+appDelegate.OnOffTime; TransparentView.alpha = 0.2; float step = 1.0 / ( appDelegate.OnOffTime * 100); for (float f = 0; f < 1; f=f+step) { TransparentView.alpha = (CGFloat)(1 - f); [NSThread sleepForTimeInterval:0.01]; } Both TransparentView.alpha = 0.2 and TransparentView.alpha = (CGFloat)(1 - f) do change TransparentView.alpha, but only TransparentView.alpha = 0.2 changes real device "brightness'. What am I doing wrong?

    Read the article

  • How to avoid Modal Storyboard infinite loop

    - by misthills
    I've written a number of iOS applications a year ago on an old version of Xcode. I've just started a new project and discovered the storyboard feature in the latest Xcode. It turns out this is perfect for the application I am writing as it consists of ~30 interlinked screens. My question is, how do I structure my storyboard and segues to allow my application to follow a circular path through my screens. I have seen a number of examples that simply segue screen 1 to screen 2 and then screen 2 to screen 1 using the modal option. This clearly works but when I debug an application built this way, it instantiates a new instance of each screen (view controller) for every segue performed. In the diagram below (apologies, I drew a nice picture but due to my newbie status, was not able to post it), how do I go from screen 1 to screen 2 to screen 3 and back to original screen 1 without creating a new instance? // Screen 1 --> Screen 2 --> Screen3 // ^ | // | | // +-------------------------+

    Read the article

  • Please explain class methods

    - by user1209902
    I'm finding it difficult to understand when it is necessary to create class methods. From what I've read, they are important for creating new objects, but I do not see how. The following class create a simple shape black rectangle. Can anyone show me how to incorporate a class method to do something that I could not do with an instance method? Shape.h #import <UIKit/UIKit.h> @interface Shape : UIView; - (id) initWithX: (int)xVal andY: (int)yVal; @end Shape.m #import "Shape.h" @implementation Shape - (id) initWithX:(int )xVal andY:(int)yVal { self = [super init]; UIView *shape = [[UIView alloc] initWithFrame:CGRectMake(xVal, yVal, 10, 10)]; shape.backgroundColor = [UIColor blackColor]; [self addSubview:shape]; return self; } @end

    Read the article

  • Cocos2d score resetting is messing up (long post warning)

    - by Jhon Doe
    The score is not resetting right at all,I am trying to make a high score counter where every time you passed previous high score it will update.However, right now it is resetting during the game. For example if I had high score of 2 during the game it will take 3 points just to put it up to 3 as high score instead of keep going up until it is game over. I have came to the conclusion that I need to reset it in gameoverlayer so it won't reset during game. I have been trying to to do this but no luck. hello world ./h #import "cocos2d.h" // HelloWorldLayer @interface HelloWorldLayer : CCLayer { int _score; int _oldScore; CCLabelTTF *_scoreLabel; } @property (nonatomic, assign) CCLabelTTF *scoreLabel; hello world init ./m _score = [[NSUserDefaults standardUserDefaults] integerForKey:@"score"]; _oldScore = -1; self.scoreLabel = [CCLabelTTF labelWithString:@"" dimensions:CGSizeMake(100, 50) alignment:UITextAlignmentRight fontName:@"Marker Felt" fontSize:32]; _scoreLabel.position = ccp(winSize.width - _scoreLabel.contentSize.width, _scoreLabel.contentSize.height); _scoreLabel.color = ccc3(255,0,0); [self addChild:_scoreLabel z:1]; hello world implement ./m - (void)update:(ccTime)dt { NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init]; CGRect projectileRect = CGRectMake( projectile.position.x - (projectile.contentSize.width/2), projectile.position.y - (projectile.contentSize.height/2), projectile.contentSize.width, projectile.contentSize.height); BOOL monsterHit = FALSE; NSMutableArray *targetsToDelete = [[NSMutableArray alloc] init]; for (CCSprite *target in _targets) { CGRect targetRect = CGRectMake( target.position.x - (target.contentSize.width/2), target.position.y - (target.contentSize.height/2), target.contentSize.width, target.contentSize.height); if (CGRectIntersectsRect(projectileRect, targetRect)) { CCParticleFire* explosion = [[CCParticleFire alloc] initWithTotalParticles:200]; explosion.texture =[[CCTextureCache sharedTextureCache] addImage:@"sun.png"]; explosion.autoRemoveOnFinish = YES; explosion.startSize = 20.0f; explosion.speed = 70.0f; explosion.anchorPoint = ccp(0.5f,0.5f); explosion.position = target.position; explosion.duration = 1.0f; [self addChild:explosion z:11]; [explosion release]; monsterHit = TRUE; Monster *monster = (Monster *)target; monster.hp--; if (monster.hp <= 0) { [targetsToDelete addObject:target]; [[SimpleAudioEngine sharedEngine] playEffect:@"splash.wav"]; _score ++; } break; } } for (CCSprite *target in targetsToDelete) { [_targets removeObject:target]; [self removeChild:target cleanup:YES]; } if (targetsToDelete.count > 0) { [ projectilesToDelete addObject:projectile]; } [targetsToDelete release]; if (_score > _oldScore) { _oldScore = _score; [_scoreLabel setString:[NSString stringWithFormat:@"score%d", _score]]; [[NSUserDefaults standardUserDefaults] setInteger:_oldScore forKey:@"score"]; _score = 0; } } - (void)update:(ccTime)dt { NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init]; CGRect projectileRect = CGRectMake( projectile.position.x - (projectile.contentSize.width/2), projectile.position.y - (projectile.contentSize.height/2), projectile.contentSize.width, projectile.contentSize.height); BOOL monsterHit = FALSE; NSMutableArray *targetsToDelete = [[NSMutableArray alloc] init]; for (CCSprite *target in _targets) { CGRect targetRect = CGRectMake( target.position.x - (target.contentSize.width/2), target.position.y - (target.contentSize.height/2), target.contentSize.width, target.contentSize.height); if (CGRectIntersectsRect(projectileRect, targetRect)) { CCParticleFire* explosion = [[CCParticleFire alloc] initWithTotalParticles:200]; explosion.texture =[[CCTextureCache sharedTextureCache] addImage:@"sun.png"]; explosion.autoRemoveOnFinish = YES; explosion.startSize = 20.0f; explosion.speed = 70.0f; explosion.anchorPoint = ccp(0.5f,0.5f); explosion.position = target.position; explosion.duration = 1.0f; [self addChild:explosion z:11]; [explosion release]; monsterHit = TRUE; Monster *monster = (Monster *)target; monster.hp--; if (monster.hp <= 0) { [targetsToDelete addObject:target]; [[SimpleAudioEngine sharedEngine] playEffect:@"splash.wav"]; _score ++; } break; } } for (CCSprite *target in targetsToDelete) { [_targets removeObject:target]; [self removeChild:target cleanup:YES]; } if (targetsToDelete.count > 0) { [projectilesToDelete addObject:projectile]; } [targetsToDelete release]; if (_score > _oldScore) { _oldScore = _score; [_scoreLabel setString:[NSString stringWithFormat:@"score%d", _score]]; [[NSUserDefaults standardUserDefaults] setInteger:_oldScore forKey:@"score"]; _score = 0; } The game overlayer .h file game over @interface GameOverLayer : CCLayerColor { CCLabelTTF *_label; CCSprite * background; int _score; int _oldScore; } @property (nonatomic, retain) CCLabelTTF *label; @end @interface GameOverScene : CCScene { GameOverLayer *_layer; } @property (nonatomic, retain) GameOverLayer *layer; @end .m file gameover #import "GameOverLayer.h" #import "HelloWorldLayer.h" #import "MainMenuScene.h" @implementation GameOverScene @synthesize layer = _layer; - (id)init { if ((self = [super init])) { self.layer = [GameOverLayer node]; [self addChild:_layer]; } return self; } - (void)dealloc { [_layer release]; _layer = nil; [super dealloc]; } @end @implementation GameOverLayer @synthesize label = _label; -(id) init { if( (self=[super initWithColor:ccc4(0,0,0,0)] )) { CGSize winSize = [[CCDirector sharedDirector] winSize]; self.label = [CCLabelTTF labelWithString:@"" fontName:@"Arial" fontSize:32]; _label.color = ccc3(225,0,0); _label.position = ccp(winSize.width/2, winSize.height/2); [self addChild:_label]; [self runAction:[CCSequence actions: [CCDelayTime actionWithDuration:3], [CCCallFunc actionWithTarget:self selector:@selector(gameOverDone)], nil]]; _score=0; }

    Read the article

  • IPhone iOs 5, need help getting my tab bar at the top to work

    - by Patrick
    I wanted to have the tab bar at the top. So i created a new project in XCode. Added a view and then inside that view i added (scrollbar, text and another view). See picture. What i wanted was to have my tab bar at the top. Then in the middle would be the contents from the tab bar and below it a small copyright text. See picture. No idea how to make this correctly. I have tried to create the UITabBarController on the fly and then assign it into the view at the top. (Top white space on the picture dedicated for the tab bar). Here is my code to init the MainWindow. MainWindow.h #import <UIKit/UIKit.h> @class Intro; @interface MainWindow : UIViewController @property (strong, nonatomic) IBOutlet UIScrollView *mainContentFrame; @property (strong, nonatomic) IBOutlet UIView *mainTabBarView; @property (strong, nonatomic) UITabBarController *mainTabBar; @property (nonatomic, strong) Intro *intro; // Trying to get this tab to show in the tab bar @end MainWindow.m #import "MainWindow.h" #import "Intro.h" @interface MainWindow () @end @implementation MainWindow @synthesize mainContentFrame = _mainContentFrame; @synthesize mainTabBarView = _mainTabBarView; @synthesize mainTabBar = _mainTabBar; @synthesize intro = _intro; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { _intro = [[Intro alloc] init]; NSArray *allViews = [[NSArray alloc] initWithObjects:_intro, nil]; [super viewDidLoad]; // Do any additional setup after loading the view. _mainTabBar = [[UITabBarController alloc] init]; [_mainTabBar setViewControllers:allViews]; [_mainTabBarView.window addSubview:_mainTabBar.tabBarController.view]; } - (void)viewDidUnload { [self setMainTabBar:nil]; [self setMainContentFrame:nil]; [self setMainContentFrame:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } @end What am i missing to get this to work? Wanted the content to end up in the scrollview so that all tabs are scrollable.

    Read the article

  • ios - how do I concatinate strings to create a url?

    - by GeekedOut
    I am trying to make a url by first collecting the parameters, and then in one statement creating the actual url. Here is what I am trying to do: NSString *urlString = @"http://www.some_login_url.com?email=%@&password=%@"; NSString *email = self.email.text; NSString *password = self.password.text; NSString *url_to_send = [NSString stringWithFormat:@"%@%@", urlString , email , password]; So what I wanted to do was replace the @ symbols with the values in the variables, but instead the second variable just got appended to the end of the string. How would I change the last line so I could put the right parameters in their correct spots? Thanks!!

    Read the article

  • Runtime error on Did End On Exit in iPhone application

    - by Deepak Pillai
    Does anyone know why im getting runtime error when i click on return button on iphone keyboard. I need to hide keyboard after done editing values to UITextField. So i assigned Did End On Exit to IBAction and the IBAction code below -(IBAction)FinishEditing:(id)sender { [folderName resignFirstResponder]; } When running ma project i facing a runtime error and the variable values shown below argv char ** 0xbffff58c *argv char * 0xbffff6b8 **argv char '/' Console Value (lldb) Any idea to overcome this issue??

    Read the article

  • Add objects to NSMutableArray

    - by iorf
    I'm trying to add objects to NSMutableArray (categoriasArray), but its not done by the iterator: @synthesize categoriasArray; for (int i = 0; i < [categories count]; i++) { categoria *cat = [[categoria alloc] initWithDictionary:[categories objectAtIndex:i]]; [self.categoriasArray addObject:cat]; cat=nil; } After the for iterator, categoriasArray has 0 objects. Many thanks

    Read the article

  • how to fetch data from Plist in Label

    - by SameSung Vs Iphone
    I have a RegistrationController screen to store email-id ,password,DOB,Height,Weight and logininController screen to match email-id and password to log-in purpose. Now In some third screen I have to fetch only the Height,Weight from the plist of the logged-in user to display it on the label.now if I Store the values of email-id and password in from LoginViewController in string and call it in the new screen to match if matches then gives Height,Weight ..if it corrects then how to fetch Height,Weight from the plist of the same one. how can i fetch from the stored plist in a string... the code which i used to match in LoginController -(NSArray*)readFromPlist { NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [documentPaths objectAtIndex:0]; NSString *documentPlistPath = [documentsDirectory stringByAppendingPathComponent:@"XYZ.plist"]; NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:documentPlistPath]; NSArray *valueArray = [dict objectForKey:@"title"]; return valueArray; } - (void)authenticateCredentials { NSMutableArray *plistArray = [NSMutableArray arrayWithArray:[self readFromPlist]]; for (int i = 0; i< [plistArray count]; i++) { id object = [plistArray objectAtIndex:i]; if ([object isKindOfClass:[NSDictionary class]]) { NSDictionary *objDict = (NSDictionary *)object; if ([[objDict objectForKey:@"pass"] isEqualToString:emailTextFeild.text] && [[objDict objectForKey:@"title"] isEqualToString:passwordTextFeild.text]) { NSLog(@"Correct credentials"); return; } NSLog(@"INCorrect credentials"); } else { NSLog(@"Error! Not a dictionary"); } } }

    Read the article

  • How to instantiate a particular view controller with storyboard in iOS at early stage of loading?

    - by dmirkitanov
    When using tabs with storyboard in iOS 5, some of them may take quite a long time to initialize when switching to it (for example, a tab containing GLKViewController). This happens because an amount of work in viewDidLoad method in this controller could be very big. Is there a way to initialize particular view controller (and call it's viewDidLoad method) defined in the storyboard at early stage - when an application starts? Having done this, the delay should be eliminated.

    Read the article

  • plus minus table View cell

    - by user1748387
    I have the following code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UIImage * i1 = [UIImage imageNamed: @"inc_01.png"]; UIImage * i2 = [UIImage imageNamed: @"inc_02.png"]; UIImage * i3 = [UIImage imageNamed: @"inc_04.png"]; UIImage * i5 = [UIImage imageNamed: @"inc_05.png"]; UIImage * i6 = [UIImage imageNamed: @"inc_06.png"]; UIImage * i7 = [UIImage imageNamed: @"inchd.png"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } if(indexPath.row == 0) { UIImageView * header= [[UIImageView alloc] initWithImage: i1]; cell.backgroundView = header; // Configure the cell… } else if (indexPath.row == 2) { UIImageView *backgroundCellImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 280, 11)]; backgroundCellImage.image=[UIImage imageNamed:@"inc_06.png"]; [cell.contentView addSubview:backgroundCellImage]; } else { // Configure the cell… UIImageView *imageView = [[UIImageView alloc] initWithImage: i3]; cell.textLabel.text = @"text"; UIImageView *backgroundCellImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 57, 46)]; backgroundCellImage.image=[UIImage imageNamed:@"inc_02.png"]; UIImageView *backgroundCellImage2=[[UIImageView alloc] initWithFrame:CGRectMake(223, 0, 57, 46)]; backgroundCellImage2.image=[UIImage imageNamed:@"inc_04.png"]; UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(57, 0, 166, 46)]; label.text = @"wow"; [cell.contentView addSubview:backgroundCellImage]; [cell.contentView addSubview:backgroundCellImage2]; [cell.contentView addSubview:label]; } return cell; } that basically creates a table view and puts an image to the left and right of each cell. I want it so that people can click on the left or right image in each cell, and something different happens based on the cell number. So if they click on the left image for cell in row 1, a function gets call with the row number they clicked on, and an indicator telling me they clicked on the left image and not the right image. How can I do that using objective-c?

    Read the article

  • Re-usable views or xibs for use with UIStoryboard

    - by Leonardo
    I find it very convenient to use storyboards, especially to have (and show) an overview of the application. However, I also find it very annoying to replicate the same code and views without the possibility to keep at least a reusable library of the most common xibs. This is especially true with UITableView and its cell. Did some of you have had any idea or best practice to share for dealing with this issue?

    Read the article

  • Read Core data in Serial Queue for iPhone app

    - by user1277209
    I have an app which uses Core data and the values are fetched from a link on internet. This runs absolutely fine when I am creating a serial queue in AppDelegate and I am not facing any problem with the same. Now, when I am trying to re-create similar scenario in a UITableViewController and executing the same in a serial queue but when the control reaches NSError *error; NSArray *match = [context executeFetchRequest:fetchRequest error:&error]; execution control disappears and then this code remains in the execution till eternity. Can anyone help me with what exactly is wrong here? FYI, I am passing the same ManagedObjectContext to the serial queue.

    Read the article

  • Detect when home button is pressed iOS

    - by nick
    I have several iOS apps that all use the same port to listen for a network beacon. On the main view I use viewWillDisappear to close the port when another view is opened, which was working great. Then I noticed if I pressed the home button from the main view controller without opening another view to close the port, then the port stays open and non of my other apps can listen on that port any more. I then tried using viewWillUnload, but that doesn't seem to get called when I press the home button. -(void)viewWillUnload { //[super viewWillUnload]; NSLog(@"View will unload"); [udpSocket close]; udpSocket = nil; } View will unload is never displayed in the console, which leads me to believe that the method is never getting called. Is there a way to detect when the home button is pressed so I can close my port?

    Read the article

  • Portrait video to landscape

    - by dappa
    I am aware questions like this one may already be out there but for the sake of others like me I will go ahead and ask I have a app that is set to only allow portrait orientation but this setting affects my videos as I would like only the videos to be able to play in landscape also. Is there a method I can add unto my .m file to make this work? Here is my code; #import "BIDVideosViewController.h" @interface BIDVideosViewController () @end @implementation BIDVideosViewController @synthesize moviePlayer ; @synthesize tableList; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; UITableView *table = [[UITableView alloc]initWithFrame:self.view.bounds]; [table setDelegate:self]; [table setDataSource:self]; [self.view addSubview:table]; tableList = [[NSMutableArray alloc] initWithObjects:@"Gangan",@"SwimGood",@"German Ice", nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [tableList count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *DisclosureButtonIdentifier = @"DisclosurebutotonIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DisclosureButtonIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DisclosureButtonIdentifier]; } NSInteger row = [indexPath row]; NSString *rowString = [tableList objectAtIndex:row]; cell.textLabel.text = rowString; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { { NSBundle *str = [tableList objectAtIndex:indexPath.row]; if ([str isEqual:@"Gangan"]) { NSBundle *bundle = [NSBundle mainBundle]; NSString *thePath = [bundle pathForResource:@"Gangan" ofType:@"mp4"]; NSURL *theurl = [NSURL fileURLWithPath:thePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl]; [moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES]; [moviePlayer play]; } else if ([str isEqual:@"SwimGood"]) { NSBundle *bundle = [NSBundle mainBundle]; NSString *thePath = [bundle pathForResource:@"SwimGood" ofType:@"mp4"]; NSURL *theurl = [NSURL fileURLWithPath:thePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl]; [moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES]; [moviePlayer play]; } else if ([str isEqual:@"German Ice"]) { NSBundle *bundle = [NSBundle mainBundle]; NSString *thePath = [bundle pathForResource:@"German Ice" ofType:@"mp4"]; NSURL *theurl = [NSURL fileURLWithPath:thePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl]; [moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES]; [moviePlayer play]; } } } @end

    Read the article

  • How to remove this bottom bar in UITabBar?

    - by flashsnake
    I am trying to do some customization on UITabBar. I am almost done with everything. However, I saw a small bar on the bottom of each UITabBarItem. I don't know what object it is. Can someone please tell me how to remove it? Or if someone can tell me how to make the UIImage inside the UITabBarItem to be displayed in front of that unknown bar. It is good enough. Cannot post image due to insufficient reputation.

    Read the article

  • how to clear a data in tableviewcell again start reload?

    - by Ios_learner
    i'm developing a bluetooth apps.1) I want to hide a tableview when i start the apps..after i pressed a action button i want to enable a tableview.. 2)if i again press a action button means tableviewcell clear the data and show empty before searching..give me an idea.. some of the code- - (IBAction)connectButtonTouched:(id)sender { [self.deviceTable reloadData]; self.connectButton.enabled = YES; [self.deviceTable reloadData]; peripheralManager = [[PeripheralManager alloc] init]; peripheralManager.delegate = self; [peripheralManager scanForPeripheralsAndConnect]; [self.deviceTable reloadData]; [NSTimer scheduledTimerWithTimeInterval:(float)5.0 target:self selector:@selector (connectionTimer:) userInfo:nil repeats:YES]; alert=[[UIAlertView alloc] initWithTitle:@"Bluetooth" message:@"Scanning" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; UIActivityIndicatorView *progress=[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)]; [alert addSubview:progress]; [progress startAnimating]; [alert show]; } tableview -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [device count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier=@"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell==nil) { cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.textLabel.text=[device objectAtIndex:indexPath.row]; cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton; return cell; } TableView Delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath]; [self performSegueWithIdentifier:@"TableDetails" sender:tableView]; }

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >