Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Thursday, October 13, 2011

iPhone | Customize the UITableView header and footer view

To Customize the table header and footer view , Just go fo it....


CGRect newFrame = CGRectMake(0.0, 0.0, self.tableView.bounds.size.width, self.myHeaderView.frame.size.height);
self.myHeaderView.backgroundColor = [UIColor clearColor];
self.myHeaderView.frame = newFrame;
self.tableView.tableHeaderView = self.myHeaderView; // note this will override UITableView's 'sectionHeaderHeight' property

// set up the table's footer view based on our UIView 'myFooterView' outlet
newFrame = CGRectMake(0.0, 0.0, self.tableView.bounds.size.width, self.myFooterView.frame.size.height);
self.myFooterView.backgroundColor = [UIColor clearColor];
self.myFooterView.frame = newFrame;
self.tableView.tableFooterView = self.myFooterView; // note this will override UITableView's 'sectionFooterHeight' property

Tuesday, February 15, 2011

iPhone : Add vibration to your iPhone App code

Add the folowing framework :
AudioToolbox.framework

Import:
#import <AudioToolbox/AudioServices.h>

Now use this line of code to make iPhone vibrate:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

Friday, January 28, 2011

how to set the title as left alignment in the UIButton in iPhone ?

Set the contentHorizontalAlignment:

btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

You might also want to adjust the content left inset otherwise the
text will touch the left border:

btn.contentEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 0);

Wednesday, July 28, 2010

iPhone: Add bar button item and set action method programmatically

UIBarButtonItem *rButton =[[UIBarButtonItem alloc] init];

rButton.title= @"someText";
[rButton setTarget:self];
[rButton setAction:@selector(aMethod)]; //aMethod defined in the class
self.navigationItem.rightBarButtonItem=rButton;

Tested & working in my project!

Happy Coding :)

Monday, July 26, 2010

iPhone : Protocols

Pointy protocol, curved category
In objective C, Pointed brackets are associated with protocols. Curved brackets are associated with categories.

Protocols are Objective C's version of what is known in .NET as "interfaces".

Defining the protocol

@protocol MyProtocolName
//Method declarations go here
@end

there are no curly brackets. That's because variables go in curly brackets, and protocols have no variables associated with them.

Notice 'NSObject'. This actually means that the current protocol is a derivative of the NSObject protocol. (There is both an NSObject class and an NSObject protocol...this is the protocol...)

The concept of protocols: Protocols are a strange & interesting cross between interfaces and event definitions. In the languages (C#, VB.NET, Java etc… ) when you define an interface, you’re defining a common set of methods that objects must implement if they want to be considered to “implement” a given interface. One of the requirements of implementing an interface is that you must implement every method in the interface, either directly or via a subclass by marking the method as abstract.
Interfaces are use frequently for implementing “event callbacks”.

We basically define a standard set of methods/events, called a protocol, that our class will call. Then, when instances of our class are created, a class implementing our protocol, called a ‘delegate’, can register itself as a handler. Take the following protocol definition below:

@protocol MyProtocolDefinition
@required
- (void) Save:(NSString*) stringToSave;
@optional
- (void) OptionalMethod:(NSString*) parameter;
@end

The above code indicates that the Save() method is a required method to implement in classes implementing this protocol. However, the OptionalMethod is optional, meaning classes wanting to use this protocol only need to implement the Save() method, but they could also implement the OptionalMethod.

Using the protocol

In Objective C, you use the pointy brackets in the interface declaration (and by "interface" here, I mean the part of the class in the header file, following the class you extend.
For example, suppose your class was normally declared like:
@interface myClass : UIView

To specify that it implements a protocol, simply change it to this:

@interface myClass : UIView


Protocols [As variables]

In Objective C, you declare a variable this way:

id myNewVariable;

So the new type is "id". "id" is the generic object.

You can also use this notation when defining a method...e.g.

- (void) doSomethingWithThisObject: (id) aObject

Enjoy Coding passionately :)

Thursday, July 1, 2010

iPhone:Add done button to number pad in iphone

Here! We will be knowing how to add 'Done' button on number pad in iphone. this is bit tricky..
Problem specification:
In IB where we can select keyboard type I have changed it to number pad and this code doesn't seem to work for me.

- (BOOL)textFieldShouldReturn:(UITextField *)textBoxName {
[textBoxName resignFirstResponder];
return YES;
}
Type: Number Pad
Return Key: Done

And Auto-enable done key is checked.


But there is no done button appears on number pad!!!!
Hopes are alive ..................
I got the solution :)

when you will see the number pad on iphone ,there is a blank space on left bottom.This is the place which I will use to put Done Image,and use it to get this number pad disappear ...
First add these two images to your resorce folder.









-(void)keyboardWillShow:(NSNotification *)note {

// create custom button

UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
// exactly of image size
doneButton.frame = CGRectMake(0, 163, 106, 53);

doneButton.adjustsImageWhenHighlighted = NO;

[doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];

[doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];

[doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];

// locate keyboard view

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];

UIView* keyboard;

for(int i=0; i<[tempWindow.subviews count]; i++) {

keyboard = [tempWindow.subviews objectAtIndex:i];

// keyboard view found; add the custom button to it

if([[keyboard description] hasPrefix:@"
[keyboard addSubview:doneButton];

}

}



//// declare it in .h

-(IBAction) doneButton:(id) sender

{
//objNumberPad is the Keyboard
[objNumericPad resignFirstResponder];

}


//

- (void)viewDidLoad {

//Notification to add done buton on num pad

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

}

- (void)viewDidUnload {

[[NSNotificationCenter defaultCenter] removeObserver:self];

}

I'm using it in live application,Hope this will resolve your problem.

Wednesday, May 12, 2010

Mobile applications development

In this era, there are huge business opportunities in mobile area. All solutions will include mobile capabilities.
The market is huge and fast-growing.
If you are interested or have already plans to create mobile apps , windows applications,office automation tools,web scrapping tools with HIGH QUALITY at LOW COSTS, we can be your best partner. Please take time to go through below text to learn how you can benefit from our resources and capabilities.
I’m now looking for opportunities of helping you to turn your great ideas and plans into wonderful products.
We are strong expertise and rich resources in developing mobile software(app & game) for iPhone etc. and have successfully delivered couple of mobile projects. We have been working with global customers. We are capable to develop complicated iPhone applications involving advanced UI effects . and windows application programming with database integration and office automation with high security & performance.

We have been always keeping pace with edge-cutting new technologies.As an integrated team ,We have established development processes involving R&D, architecture QA, performance testing, unit testing, code reviews. We adopt best practices such as iterative development, prototyping,agile, etc.

By working with us, you can get all you need – Quality in time at low cost.