How to set title in the MFMailComposerViewController? - iphone

I am trying to set the title of MFMailComposerViewController , which is a subclass of UINavigationController.
I am using these following ways :
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[picker.navigationController navigationItem].title = #"Send Mail";
[[picker navigationItem] setTitle:#"Send Mail"];
But I am not able to set the Title.
Am i doing it wrong ??
Is there any other method to do so ??
Thanks

The title is updated whenever the subject changes. You cannot change the title programmatically within AppStore restrictions. You may use -setSubject: to initialize the subject.
(A bad way to solve this is to create a very high-level window with a label that covers original title. This is very difficult to make this work with orientation change.)

Related

How to set uitextfield to italics Xcode 4.5

I have an app where the users enters information in a few textfields which are then added to a uitextview by a nsstring does anybody know how i can set one of the textfields to italics and keep the others normal
regards
Edit:
Heres my code i want to only change once textfield (e.g textfbookpublisher):
NSString* combinedString = [NSString stringWithFormat:
#"%#,%#.'%#.'%#.%#,%#.",
textfbookpublisher.text,
textfbookauthor.text,
textfbooktitle.text,
textfbookplace.text,
nameofuni.text,
textfbookyear.text];
DissertationGen*bookg = [[DissertationGen alloc] init];
bookg.message = combinedString;
bookg.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:bookg animated:YES]
A quick search would have given you an easy answer. For example, this post.
Simply set the font of the UITextfield you want to a [UIFont italicSystemFontOfSize:].
try this link see accepted answer and also check TTTAttributedLabel library
Bold one Word
now you want only textfbookpublisher in italic then pass it individually to next DissertationGen view
in DissertationGen controller's viewdidload method use following code
UILabel *lblpubl = [[UILabel alloc] init];
lblpubl.font = [UIFont italicSystemFontOfSize:18.0];
lblpubl.text = your variable which contains textfbookpublisher's text;
now use lblpubl as you wish

Changing the title of a MFMailComposeViewController

Although i know changing MFMailComposeViewController is fround upon, i'm taking a risk.
I found some ideas such as
[self presentModalViewController:controller animated:YES]; // Existing line
[[[[controller viewControllers] lastObject] navigationItem] setTitle:#"SomethingElse"];
and
[[[[(MFMailComposeViewController*)vc navigationBar] items] objectAtIndex:0] setTitle:#" SomethingElse"];
but the odd thing is that the title is "SomethingElse" for like 2 seconds and after that it returns to the subject that is set. I've tried other solutions as well but the same output.
I am using SHK (ShareKit) to connect to social. Here is the code from showViewController :
if ([vc respondsToSelector:#selector(modalPresentationStyle)])
vc.modalPresentationStyle = [SHK modalPresentationStyle];
if ([vc respondsToSelector:#selector(modalTransitionStyle)])
vc.modalTransitionStyle = [SHK modalTransitionStyle];
[topViewController presentModalViewController:vc animated:YES];
[[[[(MFMailComposeViewController*)vc navigationBar] items] objectAtIndex:0] setTitle:#" "];
[(UINavigationController *)vc navigationBar].barStyle =
[(UINavigationController *)vc toolbar].barStyle = [SHK barStyle];
self.currentView = vc;
I believe this is some kind of protection came with iOS4.
It is clearly stated here that you MUST NOT change the interface provided by Apple.
http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html
Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.
I knew some people being rejected because of this. I just wanted to warn you about this.
You just need to set the mail subject. Means [MFMailComposeViewController setsubject:#"yourTitle"]. Then this will be shown as a titile .but if you do not write anything in MFMailComposeViewController subject then by default it can show "New Message".

How can I disable re-taking of pictures?

I use the built-in camera of the Iphone in my apps dans I have two questions.
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.delegate = self;
ipc.allowsEditing = NO;
[self presentModalViewController:ipc animated:YES];
First, my camera let the user use the picture he took or Retake, I want to take off this option, the user must have only one chance to take his picture.
Second, I want a change the title of the Cancel button on the left, because my app is in french.
For the "Cancel" button, I think you may try with internalization and localization. I don't know exactly how to do.
If you want to control the camera flow, it is harder than the normal way. You have to replace the default control buttons (in the bottom of the camera screen) with your own control. There are 2 methods that you need to do:
First, you need to set showCameraControls to NO: picker.showCameraControls = NO
#property(nonatomic) BOOL showsCameraControls
Then you need to supply your own view: picker.cameraOverlayView = YOUR_OWN_VIEW
#property(nonatomic, retain) UIView *cameraOverlayView

navigationItem.prompt & UIImagePickerController

Is it possible to make calls to navigationItem on a UIImagePickerController? Specifically, the image picker? Below I've linked an image of what I'm trying to achieve ( screen shot taken from another app doing the same thing). Once the user selects an image from the picker the navigationItem.prompt is set and, though I think it might be a HIG violation, the right bar button is changed from the standard cancel button. I can set the prompt on a "normal" view no problem with:
self.navigationItem.prompt = myString;
But this does not seem to work when I try to use it in the context of a picker with:
myPicker.navigationItem.prompt = myString;
I've tried using it when the picker is created and also in didFinishPickingMediaWithInfo: which is really where I need to set it as I'm letting the user select multiple images instead of dismissing the picker as soon as one image is selected. Nothing seems to work.
Here's a image of the desired behavior:
http://i51.photobucket.com/albums/f353/zoso5th/after.png
Someone answered this for me on the Apple dev forums:
UINavigationBar *bar = picker.navigationBar;
UINavigationItem *navItem = bar.topItem;
navItem.prompt = #"Some new prompt";
I wasn't correctly accessing the navbar.
Someone answered this for me on the Apple dev forums:
UINavigationBar *bar = picker.navigationBar;
UINavigationItem *navItem = bar.topItem;
navItem.prompt = #"Some new prompt";
I wasn't correctly accessing the navbar.
Use the code after calling 'presentModalViewController'.....like below...
[controller presentModalViewController:imagePickerController animated:YES];
UINavigationBar *bar = picker.navigationBar;
UINavigationItem *navItem = bar.topItem;
navItem.prompt = #"Some new prompt";

Just how to you use TTStyledTextLabel?

All I want is to display some simple text in my viewController and have the hyperlinks autoparsed. When the user clicks on the link I want the control to somehow do a callback where I can do something with the URL. How can I achieve this?
I've already looked through the TTCatalog for hours. I have also tried looking into the source code of three20 as well as looking at the stack trace. No help. I just can't figure out how my app can react to the click of the URL. Any hints please?
Hard to help without seeing what you've already tried, but you should be able to do something like the following:
TTStyledTextLabel* label = [[[TTStyledTextLabel alloc]
initWithFrame:someFrame] autorelease];
NSString* labelText = #"This should work";
label.text = [TTStyledText textFromXHTML:labelText lineBreaks:NO URLs:YES];
[someView addSubview:label];
You can then use TTNavigator and TTURLMap to map custom-uri://some/url to a particular controller in your application, or handle it yourself in your application delegate. The best place to find out how to do that is by looking at the TTNavigatorDemo sample application included in the Three20 source. Specifically, look at AppDelegate.m which is where all the URL mapping gets performed.
In addition to what Nathan says about URL mapping and links, you can also use CSS styles!
TTStyledTextLabel* label = [[[TTStyledTextLabel alloc] initWithFrame:someFrame] autorelease];
NSString* labelText = #"This should work and
<span class=\"redText\">this should be red</span>";
label.text = [TTStyledText textFromXHTML:labelText lineBreaks:NO URLs:YES];
[someView addSubview:label];
Then in your StyleSheet.m implement
- (TTStyle*) redText {
return [TTTextStyle styleWithFont:[UIFont systemFontOfSize:12] color:RGBCOLOR(255,0,0) next:nil];
}