w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
UITableview datasource and delegate
Hover over the connections in Interface Builder. A small 'x' should appear, click it. This will break the current connections. Drag from the (now open) circle next to each property over to the new dataSource and delegate. This will set the new connections. None of this will change the class shown in Interface Builder.

Categories : Iphone

Two UITableView in the same class? datasource and delegate
You can do this by looking at the tableView argument that was passed in. Example: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.tableView1) { return [dataTable1 count]; } else /* tableView == self.tableView2 */ { return [dataTable2 count]; } } With this pattern, you need to put if statements in all of your UITableViewDataSource and UITableViewDelegate methods. Another way to do it is to make one method that returns the array of data for the table view: - (NSArray *)dataTableForTableView:(UITableView *)tableView { if (tableView == self.tableView1) { return dataTable1; } else /* tableView == self.tableView2 */ { return dataTable2; } } Then use that function in ea

Categories : IOS

UITableView datasource methods not called on reloadData in IOS
someTable = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain]; You have already bind your UITableView from nib/storyboard. In this case you did not have to alloc again the tableview. Removing this line will do the work

Categories : IOS

Multiple delegate or datasource connection on the storyboard
You can see all the relationships of a view-controller at a time in "connection inspector "by selecting a whole view controller. You have to select a certain control on view-controller then you are able to see its corresponding relations that is delegates,connections or events in "Connection (Relationship) inspector". On multiple selection of controls xcode shows you blank window in "Connection (Relationship) inspector".

Categories : IOS

Is it possible to connect delegate and dataSource of CustomViews in interface builder?
You'll need to meet these conditions: The view's Custom Class should be set to your custom view's class name in Interface Builder (via the Identity Inspector). If your delegate or dataSource object is also a custom view, also make sure that that view's Custom Class is set The @interface for your custom class should decorate its delegate and dataSource properties with IBOutlet. For example, @property (nonatomic, weak) IBOutlet id <SomeProtocol> delegate; If you declared protocol(s) for your delegate or dataSource, the target object that you want to use as the delegate or dataSource should be declared as implementing that protocol

Categories : IOS

How to set the datasource of a UITableView in code
'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' This is what is causing your app to crash. Something in the logic of your tableView:cellForRowAtIndexPath method is keeping a UITableViewCell from being returned. That log message says it all -- A UITableViewCell must be returned from tableView:cellForRowAtIndexPath:.

Categories : IOS

UITableView Dynamic Datasource
This sounds like a great opportunity to introduce a separate service for managing your network requests instead of embedding that behavior in the middle of your table's datasource. If your datasource were to request that this service try to load the next 50 cells then that service can decide if it should actually start a new network request or not. Let your instance of that service keep track of what requests are in flight and what ranges of index paths they are expected to cover so it can decide when a -shouldLoadItemsStartingAtIndexPath: style message should result in a new network request. Is that the sort of pattern you are looking for or did you have a more specific question about your approach?

Categories : Iphone

UITableView calling wrong DataSource
I think your app is trying to access datasource using deallocated instance, you better have individual classes for each tableView, it will simplify your work, always try to modulize the classes instead of trying to put everything in just one class.

Categories : IOS

Using calendar days as UITableView datasource in iOS
I think I found a fairly decent approach to this that I have implemented, so I'll answer my question. My datasource instances an array of NSDates that's spans 12 months. As I pull NSDate references from the datasource, it monitors the current index that is being used. When the index starts getting close to the lastObject in the array, the datasource model goes ahead and generates an additional 6 months worth of NSDates. Since I am increasing the number of objects in my datasource (within my model) I added a BOOL property called setNeedsNumberOfItemsRefreshed. I then setup a KVO with my View Controller as the observer, observing the setNeedsNumberOfItemsRefreshed property. When I add items to the datasource, I set the setNeedsNumberOfItemsRefreshed = YES and my View Controller invokes re

Categories : Iphone

Obj-C: UITableView update datasource cross-class
Expose your "playlists" array as a public property on your view controller. Implement a custom setter that prompts the tableview to reloadData when set: @property (strong, nonatomic) NSArray* playlists; ... @synthesize playlists=_playlists; ... - (void) setPlaylists: (NSArray*) playlists { _playlists = playlists; if ( self.isViewLoaded ) { [self.tableView reloadData]; } }

Categories : Objective C

UITableView datasource / reload race condition
If I understand your question correctly, I would use global flag to lock data changes. e.g. use singleton pattern to hold your flag value. Check whether flag is locked or not. If flag is locked, do not call or disable data change methods. When UITableView is updating, lock flag until updating is finished.

Categories : IOS

Is DataSource Pattern used with UITableView an example of dependency injection?
Yes, it can be considered an example of dependency injection. A simple definition of dependency injection is: Dependency injection is a design pattern where an object's dependencies and collaborators are set by an external entity, not by themselves. With the UITableViewDataSource protocol we actually separate the UITableViewController itself from the data source it needs to do its work. That means that the class that creates the UITableViewController can configure it with whatever data source it wants, improving its reusability and testability (two common goals of dependency injection).

Categories : IOS

Clean approach for refreshing UITableView data from datasource
You can call [dictB addEntriesFromDictionary:dictA]; and that should copy everything from dictA into dictB. Now you may have to clear out dictB before doing so, but it should work NSMutableDictionary Something a simple as dictB = [dictA copy]; may also work. Not sure though if that has problems with retain counts, or anything like that.

Categories : IOS

UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath"
The cell identifiers you use in your storyboard are actionCell and plainCell. actionCell. Not attentionCell. Use the correct cell identifier in your code if (urgentRange.location == NSNotFound) { identifier = @"plainCell"; } else { identifier = @"actionCell"; }

Categories : IOS

Disable delegate method for UIPickerView/UITableView on conditional case
There are two ways you can do it. 1) Make Delegate Null Set a condition when you do not want to call the method and at that place make delegate = nill. And again Reset it delegate =self when needs to call the method. The second method which I must say Better one 2) Use flag inside the Delegate method Try to implement if-condition (Flag) inside the method and set its TRUE and FALSE values as per requirement. for ex. -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { if(x == YES) { // Only this code need to implement } else { return; } }

Categories : Iphone

UICollectionView datasource not being called
I think there are several things wrong here--and there are some complexities to view controller containment that you may need to read up on. First off, you're not adding the EVPhotoCollectionViewController view as a subview of your vc, eg: [self addSubView:pc.view]; Also, you're not setting a frame for the EVPhotoCollectionViewController, so depending on how it's implemented, it might not show up with the right size/position. Lastly, it doesn't look like you're retaining the EVPhotoCollectionViewController anywhere. Its view will be retained by the view hierarchy, but it looks like the instance of EVPhotoCollectionViewController will be dealloc'd once the function creating it goes out of scope. View controller containment: How does View Controller Containment work in iOS 5?

Categories : IOS

Delegate method is not called (is nil)
How to use delegate in correct way! In SecondViewController.h: @protocol messageDelegate <NSObject> @optional -(void) test; @end @interface SecondViewController : NSString @property (nonatomic, assign) id <messageDelegate> delegate; @end In SecondViewController.m: -(void)readyToSend { [self.delegate test]; } In ViewController.h: @interface ViewController : UIViewController<messageDelegate> @end In ViewController.m: in - (void)viewDidLoad { SecondViewController *secondViewController = [[SecondViewController alloc] init]; secondViewController.delegate = self; } -(void) test{ NSLog(@"Delegate massage is received!"); } Hope it will help!

Categories : IOS

delegate method not getting called
I think it is because you did not hold the reference to the instance of the delegate, and it got released because it is declared weak. You might be doing this: pdfView.delegate = [[points alloc] init]; which you should fix to something like: _points = [[points alloc] init]; pdfView.delegate = _points; where _points is instance variable.

Categories : Objective C

shouldStartLoadWithRequest delegate method never called
If your Controller instance adds itself as the delegate then the method you add to the AppDelegate instance will never be called. Move the shouldStartLoadWithRequest method into your Controller class.

Categories : Iphone

Delegate methods not called when being hidden
have you set the delegate to self in that ViewController and also have mentioned/implemented the delegate in .h file of yourViewController as below. yourViewController.h @interface yourViewController : UIViewController<yourDelegate> yourViewController.m [yourComponent setYourDelegate:self];

Categories : Iphone

NSFetchedResultsController delegate not called for API listener
The problem is that an initial - (BOOL)performFetch:(NSError **)error is never called since this particular code only cares about changes to the result set, not the initial set. However, it would follow that the controller would not notice changes in data it never had. Changing the init method as follows fixes the problem: -(id)initWithFetchedResultsController:(NSFetchedResultsController*)fetchedResultsController { self = [super init]; if (self != nil) { fetchedResultsController.delegate = self; _fetchedResultController = fetchedResultsController; [fetchedResultsController performFetch:nil]; } return self; }

Categories : IOS

GKMatchmakerViewController delegate methods not being called
The solution was that I was missing the fact that the controller delegate is not the correct delegate to set! Use matchmakerDelegate and all will be well! controller.matchmakerDelegate = self;

Categories : IOS

reloadData not working (called in delegate)
Make sure you are sending the reloadData message from the main thread, otherwise you can have problems. It appears that the TitleItemsReturned method may not be called from the main thread (e.g. from a background thread in a NSURLConnectionDelegate method implemented by the networkLayer object, or a similar delegate method). If TitleItemsReturned is indeed not being run on the main thread, you can do this inside of TitleItemsReturned: dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; }); The searchBarCancelButtonClicked method is working because that method is running on the main thread (from a UI event).

Categories : IOS

PageViewController delegate functions called twice
Replace these two methods and compile, - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { NSUInteger index = [(APPChildViewController *)viewController index]; if (index == 0) { self. view.backgroundColor = [UIColor redColor]; return nil; } if(index == 1) { self.view.backgroundColor = [UIColor blueColor]; } if(index == 2) { self.view.backgroundColor = [UIColor greenColor]; } if(index == 3) { self.view.backgroundColor = [UIColor brownColor]; } /*if(index == 4) { self.view.backgroundColor = [UIColor whiteColor]; }*/ // Decrease the index by 1 to return index--;

Categories : IOS

Delegate gets called but the calling viewcontroller is released
My guess is that at in the delegate method the content of self.inviteSponsorsFromVC is nil. In Objective-C, when you send a message to nil the message is simply ignored (unlike C++, for instance, where you get a crash when you call a method on a NULL object). As an experiment you can try either one of these: If you use ARC, make the property self.inviteSponsorsFromVC a strong reference If you don't use ARC, say [self.inviteSponsorsFromVC retain] at some point before you display the action sheet Either way, what you need to do is to make sure that the object in self.inviteSponsorsFromVC is not deallocated before you invoke a method in it. EDIT after your comment The property declaration is good, it's got the strong attribute on it. In your InviteSponsorsFrom class, try to add a dea

Categories : Objective C

Delegate method not being called when using xmpp framework
Connecting When you're ready, you can start the connection process: NSError *error = nil; if (![xmppStream connect:&error]) { NSLog(@"Oops, I probably forgot something: %@", error); } As you are not doing anything the delegate methods are not called. Depending on XMPPStream implementation you'll most likely get tons of memory issues, add somewhere a retained reference to the allocated object.

Categories : Iphone

Trying to get current location, but LocationManager delegate never get called
May be you are running the code on simulator and SDK is below 6.0. In this case you get only 0.0000 as latitude and longitude. And make sure that application is granted access to device location. If you just want to get current location then do the following : -(void)getCurrentLocation { self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; [self.locationManager startUpdatingLocation]; CLLocation currentLocation = self.locationManager.location; [self.locationManager stopUpdatingLocation]; } BTW, never use self when initialize any object. Because doing this creates 2 object. first object is created by right side of this line self.locationManager = [[CLLocationManager alloc] init];. Second object is created when set

Categories : IOS

glkview drawinrect delegate method called only once
Problem solved: Here is my code @class HelloGLKitViewController; @interface UserInterfaceViewController : UIViewController { HelloGLKitViewController *myHLKViewController; } @end @implementation UserInterfaceViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. NSLog(@"viewDidLoad of userinterfaceUiViewController"); myHLKViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:NULL] instantiateViewControllerWithIdentifier:@"HelloGLKitViewController"]; [self.view addSubview:myHLKViewController.view]; [self addChildViewController:myHLKViewController]; [myHLKViewController didMoveToParentViewController:self]; } @end Thanks for the ref link Using GLKView with a UIViewController

Categories : Iphone

When using everyplay sdk v 1.6+, AVAudioPlayer delegate are not called anymore
AVFoundation AVAudioPlayer recording support was enabled on Everyplay v1.6. However the delegate methods are not called. This will be fixed soon in the next update. Meanwhile you can disable the AVFoundation support by creating EveryplayFeatures.h and EveryplayFeatures.m to your xCode project with the following contents. EveryplayFeatures.h #import <Foundation/Foundation.h> @interface EveryplayFeatures : NSObject @end EveryplayFeatures.m #import "EveryplayFeatures.h" @implementation EveryplayFeatures (Private) + (BOOL) supportsAVFoundation { return NO; } @end

Categories : Iphone

delegate methods are not called and parse property is always FALSE
Is there a reason you're cramming your XML parser inside the AppDelegate? Without exception I've found it to be beneficial to always instantiate a parser class to handle parsing tasks. For example... myParser.h @class parseClass; @interface myXMLParser : NSObject <NSXMLParserDelegate> { } - (myXMLParser *) initmyXMLParser; myParser.m //I do my instantiating like this so it can only be done once //If you need to instantiate the class more than once do NOT use dispatch_once! - (myXMLParser *)initmyXMLParser { static myXMLParser *newInstance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ newInstance = [[myXMLParser alloc]init]; }); return newInstance; } //include other delegate methods as well AppDelegate.m #import "myPar

Categories : IOS

application:openURL:sourceApplication:annotation: not called in app delegate
You have to tell the phone that your app accepts certain files. You do this by going to the info.pList and there you add a flag. Follow this link which will cover this subject. https://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html%23//apple_ref/doc/uid/TP40010411-SW1

Categories : IOS

Paint event delegate not invoked when refresh() method is called
What you did should have worked, but Microsoft say you should override OnPaint() rather than subscribing to the Paint event, to paint a user control. As it says in the documentation for Control.Paint: When creating a new custom control or an inherited control with a different visual appearance, you must provide code to render the control by overriding the OnPaint method. See here for more details: http://msdn.microsoft.com/en-us/library/cksxshce.aspx But do note that doesn't really apply to Form classes (such as the one you're using), which are not User Controls or Custom Controls! Nevertheless, it's still more usual to override OnPaint() to paint the control itself.) You should try adding the following to your form: protected override void OnPaint(PaintEventArgs e) { // Call t

Categories : C#

UITableView didselectrowatindexpath not getting called
Update answer From your comment below, I see what you're getting at. You're trying to fake a custom selected background for grouped style (which can't be customized without providing custom images) by turing of selection highlighting and instead setting the unselected background color when the cell is tapped. You can do this in shouldHighlightRowAtIndexPath: - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.backgroundColor = [UIColor greenColor]; return YES; } This method gets called before didSelectRowAtIndexPath even when selection style is none. You'll need to elaborate on the above solution to set the color back when the cell is supposed to be unhi

Categories : IOS

How to make viewWillAppear to be called when we use a subclass of UITableViewController to handle table delegate?
Make the table view controller a child view controller of your view controller while its view is linked (and it is the data source) and could be on screen. This tells the view controller hierarchy that the table view needs to know about the appearance callbacks.

Categories : Objective C

will CBCentralManager ,CBService delegate methods be called in background mode in iOS6
I believe what you are looking for are the core bluetooth UIBackgroundModes here. Also, you may want to look at Core Bluetooth and backgrounding: Detection of a device and triggering an action, even after being days in background mode? and What exactly can CoreBluetooth applications do whilst in the background? The core bluetooth background modes work in iOS 5 or later.

Categories : IOS

initWithStyle not being called in UITableview from storyboard
When using the Interface Builder, you should put initialization code in this method instead: - (void)awakFromNib { } Note: There is no [super awakFromNib] to call though and don't call [super initWithStyle] either. It should also be noted that many UI elements in the controller may not yet be initialized in awakFromNib so some of that should be better accessed in viewDidLoad.

Categories : Iphone

RowSelected not being called in UITableView in iOS using Xamarin
THANK YOU JASON !!! You nailed it. I was calling the base class and I shouldn't: public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { base.RowSelected(tableView, indexPath); if (DeviceSelected != null) { DeviceSelected(tableView, Devices[indexPath.Row].FoundDevice); } } Just needed to remove call to base.RowSelected(..): public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (DeviceSelected != null) { DeviceSelected(tableView, Devices[indexPath.Row].FoundDevice); } } Now it works just fine. Thanks JASON !!!

Categories : IOS

When is tableView:numberOfRowsInSection: called in UITableView?
The method is called very first time the tableview is getting loaded and if you are more interested in the delegates then put a breakpoint and check when and where which delegate is called and how many times.

Categories : IOS

UITableView reloadData does not seem to cause cellForRowAtIndexPath: to be called
After reloadData, try this: NSIndexSet * sections = [NSIndexSet indexSetWithIndex:0]; [self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationNone]; I found if the data change is subtle, the table view seems to optimize away the need to refresh.

Categories : IOS

objective-c passing data from a delegate to the initial calling class (getting data for a uitableview)
Try this , hope helps u .. :) #import <Foundation/Foundation.h> #import "AppDelegate.h" @class FbApi; @protocol FbApiDelegate <NSObject> -(void)didLoadRequestForTableview:(NSMutableDictionary *)aDict;//change the delegate method @end @interface FbApi : NSObject @property (assign, nonatomic) id <FbApiDelegate> delegate; @property (strong, nonatomic) NSMutableDictionary *json; -(void)fbIDInformation:(NSString *)fbID to:(NSMutableDictionary *)dict; @end // FbApi.m #import "FbApi.h" @implementation FbApi -(id)init { self = [super init]; if (self) { } return self; } -(void)fbIDInformation:(NSString *)fbID to:(NSMutableDictionary *)dict { NSLog(@"i am in FbApi mode. DOING A NEW REQUEST"); NSString *fbquery = [NSStrin

Categories : Objective C



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