Hi friends i want know sectionIndexTitlesForTableView Action is works
i have the following code... but i want to call the web services with A/B/C/D.... Z as parameter.. So i need to know how it is?
My actual need is the products list in with starting letter As A in default , when click on B then i want to show the Product list with Starting letter as B. And also i want A.to..Z in the Right side for table view for select the letter... so i tried this but i dont know how to give the Action so please help me..
selectArray = [[NSMutableArray alloc] initWithObjects:#"A",#"B",#"C",#"D",#"E",nil];
Method is:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return selectedArray;
}
I solved my Question as shown below
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
if (title) {
[self webCall:title];
[tableData setArray:nil];
[table reloadData];
}
return 1;
}
Related
I need to Delete All the records in a list applet by a button clicked method. In order to achieve this, I have added a button to the list applet with "DeleteAllRecords" method and added a script to BC PreInvokeMethod function as below. Once clicked on the button all the records will get deleted, but the applet won't get refreshed. How Can I achieve that?
try
{
if(MethodName == "DeleteAllRecords")
{
var EmpBO = TheApplication().GetBusObject("XXXX");
var EmpBC = EmpBO.GetBusComp("XXXX");
with(EmpBC)
{
SetViewMode(AllView);
ActivateField("EmployeeID");
ClearToQuery();
SetSearchExpr("[XXXX] <> ' '");
ExecuteQuery(ForwardOnly);
var Frecord = FirstRecord();
while(Frecord)
{
Frecord = DeleteRecord();
Frecord = FirstRecord();
}
}
//BC.InvokeMethod("RefreshBuscomp");
return (CancelOperation);
}
}
catch(e)
{
throw(e);
}
finally
{
EmpBO = null;
EmpBC = null;
}
return (ContinueOperation);
You could try a few things.
1: A simple null query in the end after all deletions are done. ClearToQuery() and ExecuteQuery();
2: There is a BC method for RefreshBusComp (check documentation) which can be used with InvokeMethod(). Does pretty much the same thing as 1. I see you already tried it and probably did not work.
3: There are Business services which can refresh applets , like FINS Teller UI navigation.
4: You could also try a null query in browserscript/javascript, put that in InvokeMethod, so that it runs after the BC escript. Genb has to be run to generate bscripts.
One of these should work .
I have one layer called alayer, and there is a button called abutton, when click the button, another layer called blayer will show in alayer, not replaceScene, please look at the following code,
alayer.m
-(void)abuttonclicked:(id)sender
{
blayer *blayer = [blayer node];
blayer.position = ccp(1,1);
[self addChild:blayer];
}
blayer.m has a button called bbutton and string value called bstring, I want to click the b button, it will close blayer (remove blayer from alayer), and pass the string value bstring to alayer, please look at following code,
-(void)bbuttonclicked:(id)sender
{
// how can do here to close its self(remove its self from alayer), and pass the bstring to alayer?
}
thanks.
ps. I can use NSUserDefault to pass the string value, but I think it's a bad way to do this, is there another way to pass value?
maybe to pass the string you could declare and implement a property in ALayer.h/.m
#property(nonatomic,copy) NSString *stringFromLayerB;
to remove bLayer when bButtonClicked :
-(void)bbuttonclicked:(id)sender
{
ALayer *lay = (ALayer*) self.parent;
lay.stringFromLayerB = #"Whatever you want to set";
[self removeFromParentAndCleanup:YES];
}
There are other ways to do this. You could implement a callback mechanism , use notifications, some kind of delegate protocol binding BLayer and ALayer. All depends what your real (unsaid) requirements are.
Considering your scenario, I think its better to use NSNotificationCenter.
You can post notification from blayer when the button is tapped and add an observer in alayer to respond exactly how to want.
Add [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(receivedNotification:) name:#"BlayerNotification" object:nil]; in alayer's init and [[NSNotificationCenter defaultCenter] removeObserver:self]; in its dealloc.
Its selector like:
- (void)receivedNotification:(NSNotification *)notification {
NSString *string = (NSString *)notification.object;
NSLog (#"String received %#", string);
}
Now you can post notification from blayer when hte button is clicked:
-(void)bbuttonclicked:(id)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:#"BlayerNotification" object:self];
[self removeFromParentAndCleanup:YES];
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:
(NSInteger)component {
if(thePickerView == self.countryPicker){
self.countryLbl.text = [self.responseArray objectAtIndex:row];
}
}
- (IBAction)countryDoneBtn:(id)sender {
// Picker first row selected on done button
[self.countryLbl setText:[NSString stringWithFormat:#"%#", [self.responseArray
objectAtIndex:[self.countryPicker selectedRowInComponent:0]]]];
[self myViewDown:self.countryView];
[self.durationView removeFromSuperview];
//[post selectState:[self.responseArray objectAtIndex:row ]];
}
i want to do this "[post selectState:[self.responseArray objectAtIndex:row]];"
but can't access "objectAtIndex:row" here in this "- (IBAction)countryDoneBtn:(id)sender"
method.
Please friend help me how can i access the row from this IBAction
Thanks in advance need your help i'm new in iphone development
The row variable is not available because the row you are looking for is only passed in the delegate method didSelectRow:inComponent of the picker view.
Based on you are trying to do, you can still get the selected row of the picker with the method selectedRowInComponent, which you have already used to set the text of the countryLbl.
So, just use the same method to get the object from your responseArray:
NSInteger selectedRow = [self.countryPicker selectedRowInComponent:0];
[post selectState:[self.responseArray objectAtIndex:selectedRow]];
How do I create a CCMenuItem list dynamically?
//Returns me an array with my items
Items *items = [ItemParser loadItemsForLevel:selectedLevel fromSuperLevel:selectedSuperLevel];
For an item I have a string with the name of the item that I'd like to display in my CCMenu. The number of items could vary but I want to display only 6 items at a time
and how do I remove it? I'm cleaning up from the CCLayer but I'd like to do it also from the menu list
Anyone?
Cocos2D does not provide a method to do this.
You may create your own initializer based on the original one found in "CCMenu.m".
The original looks like this (I removed code that does not add items here for clarity). Create your own init method based on the original and add a variable amount of items instead. If you like you may also set it up as a category to CCMenu.
-(id) initWithItems: (CCMenuItem*) item vaList: (va_list) args
{
if( (self=[super init]) ) {
// ... code cut for clarity
if (item) {
[self addChild: item z:z];
CCMenuItem *i = va_arg(args, CCMenuItem*);
while(i) {
z++;
[self addChild: i z:z];
i = va_arg(args, CCMenuItem*);
}
}
// ... code cut for clarity
}
return self;
}
Update:
When your menu items change then rebuild the whole menu.
I have a CCLabelAtlas that I have on a layer to display the current score within my game...the problem that I am having with it is that it does not update when I use [scoreLabel setString:]. Here's how I have it laid out:
In the header:
#interface GameScene : CCLayer {
...
CCLabelAtlas* scoreLabel;
}
And in the init:
scoreLabel = [[CCLabelAtlas alloc] initWithString:#"0" charMapFile:#"scoreCharMap.png" itemWidth:6 itemHeight:8 startCharMap:'.'];
[scoreLabel setPosition:ccp(105, 414)];
[self addChild:scoreLabel z: 6];
scoreCharMap.png is a custom map that includes ./0123456789 of my desired font. When the score is changed, I attempt to do this to get the label to update with the current score:
NSString* str = [[NSString alloc] initWithFormat:#"%d", [[GameRunner sharedInstance] currentScore]];
[scoreLabel setString: str];
[str release];
[scoreLabel draw];
Problem is that it doesn't ever update - it just sits there and displays 0. I know for a fact due to breakpoints and debugging that setString is being called, and that the string that it should be displaying is correct - but it just doesn't update. Hard-coding the value and saying [scoreLabel setString:#"1234"] does nothing, either. What am I doing wrong here? I am using Cocos2d 0.99 - thanks in advance!
Maybe this is something wrong with the font you are using? Try using one of the font maps that came with Cocos2D and see if it works for you.
The method -[CCLabelAtlas setString:] does a few things.
Can you verify that following goes right: (place a breakpoint and step through the function)
resizeCapacity doesn't fail to resize
updateAtlasvalues retreives a UTF8 character array pointer. Inspect that to see if that's the correct string, and while you're there, inspect n in the same method, which should be your string length
See code for setString below:
- (void) setString:(NSString*) newString {
if( newString.length > textureAtlas_.totalQuads )
[textureAtlas_ resizeCapacity: newString.length];
[string_ release];
string_ = [newString retain];
[self updateAtlasValues];
CGSize s;
s.width = [string_ length] * itemWidth;
s.height = itemHeight;
[self setContentSize:s];
}
Let me know what the results are, if you still need any help.