UITextField cuts/hidden from the half first row - until touching - iphone

I have this really unanswered question.. after looking in the web for this problem i tring my luck with you..
i have a UITextView that gets the string from url.
but... the textfield is cuts/hidden fron the half first row and its fixed only when i touch it.
this is the code:
- (NSString *)getMonthValues{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#/%#",URL_ADDRESS2,URL_MONTH_ZODIAC]];
NSString *Value = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
Value = [Value stringByReplacingOccurrencesOfString:#"\\n" withString:#"\n"];
}
-(void)getMonthValue{
NSString *horoscope_daily = [self getMonthValues];
[Month_horoscope setText:[NSString stringWithFormat:#"%#",horoscope_daily]];
}
can someone please explain this problem and help me fix it ?!

It is either 1) covered by other view, or 2) has a frame too small to see the whole text.
To check out the cover issue, try setting background property to [UIColor redColor], on all other visible views.
And if it is the frame issue, right after you setText, issue:
[Month_horoscope sizeToFit];

Related

How to display the created file name and contents on textview?

How to display the created file name and contents on textview? This is my code. Iam able to display the file name and its contents in NSLog but not on textview though i have given the outlet for textview. Please help me with this issue.
-(IBAction) open: (id) sender
{
// Create instance of UITextView
textView = [UITextView alloc];
initWithFrame:[[UIScreen mainScreen] applicationFrame]];
NSString *homeDir = NSHomeDirectory();
// Add text
textView.text= homeDir;
NSLog(#"%#", homeDir);
textfield.text= #"output will go here..";
NSString *myFilePath = [[NSBundle mainBundle]
pathForResource:#"Myfile"
ofType:#"txt"];
NSString *myFileContents = [NSString stringWithContentsOfFile:myFilePath
encoding:NSUTF8StringEncoding
error:nil];
NSString *s = [NSString stringWithFormat:#"myFilePath: %#, Contents of file:%#",myFilePath, myFileContents];
NSLog(#"%#", s);
textView.text= s;
}
Does the textView work at all? Have you tried:
textView.text = #"TestText"? If the textView remains empty you need to check the outlet/ check whether the textView is added to the ViewController properly. I think this should solve your problem.
There is an issue with your text view setup.
If an outlet is connected to the text view, you do not need to create it in code (which you are doing).
If you create it in code, you have to add it as a subview to the desired view (which you are not doing).
I think you forgot to add the textview in your parentview; I assume you are creating runtime textview. Just add this line in your code.
[self.view addSubview:textView];

UIlabel into a url?

i created a uilabel that contains my location data using this code,
longitudedata.text = [NSString stringWithFormat:#"longitude=%f", location.coordinate.longitude];
speeddata.text = [NSString stringWithFormat:#"speed=%f", [location speed] * 2.2369];
altitudedata.text = [NSString stringWithFormat:#"altitude=%f", [location altitude]];
but now i need to add these in a url so it will send that data to my server but everything iv tried dosnt work :(
NSURL *myURL = [NSURL URLWithString:[#"http://servername/ldtracker.aspx?id=3&" stringByAppendingString:longitudedata.text]];
and so on but this dosnt work, seems like iv tried everything
im a beginner to xcode, please help :)
UILabels dont handle urls, u need to give them a NSString.
label.text = [NSString stringWithFormat:#"http://servername/ldtracker.aspx?id=3&%#", longitudedata.text];
this should work if i understood ur problem correctly
NSURL *myURL = [NSURL URLWithString:[NSString stringWithFormat:#"http://servername/ldtracker.aspx?id=3&%#&%#%#",longitudedata.text,speeddata.text,altitudedata.text]];

iphone timer plist file display

I'm going to ask this question again,I thought I had figured it out but I guess not. This is for a timer app that gets the timer info from a plist file. Everything works but I want the .plist extension not to show in my tableview. Here are two code snippets that I believe are the issue. These are in an array called NSArray *files;
self.files = [[NSBundle mainBundle] pathsForResourcesOfType:#"plist" inDirectory:#"Timers1"];
// Configure the cell.
cell.textLabel.text = [[files objectAtIndex:indexPath.row] lastPathComponent];
return cell;
Thanks for the help
NSString *text = [[files objectAtIndex:indexPath.row] lastPathComponent];
text = [text substringToIndex:[text rangeOfString:#"."].location];
cell.textLabel.text = text;

MFMessageComposeViewController not displaying camera icon

When I bring up a "New Message" manually I will see a camera icon to the left of the text edit area. When I use the MFMessageComposeViewController it will not display this icon which means you cannot insert images. I know this can be done because the guys that made txtAgif can do it. One subtle difference is the Caps is turned on. This might be a clue as to how they are getting this to work.
I know that MFMessageComposeViewController does not allow you to insert images programmatically and that is why I'm doing the copy to UIPasteboard trick. This part works perfectly.
This same question has been asked here and here the question has not been answered except for the "It can't be done."
This is my first post so I did not have a high enough ranking to contribute to the other question posts.
How are they doing this? Is there a trick to MFMessageComposeViewController or are they using something completely different?
I have fixed this by following code:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = YES;
NSString *imagefile =app.strimagepath;
///
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagefile];
if (fileExists)
{
NSData *data = UIImagePNGRepresentation([UIImage imageWithContentsOfFile:imagefile]);
pasteboard.image = [UIImage imageWithData:data];
}
NSString *phoneToCall = #"sms: 123-456-7890";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
Here app.strimgPath is the path of image stored in document directory. when the MessageView is opened. Longpress and click on Paste and message will be pasted.
I found the answer! Using UIApplication sharedApplication to launch a blank message works while MFMessageComposeViewController does not. Because I'm using the UIPasteboard I do not need to insert items into the body.
NSString *phoneToCall = #"sms: 123-456-7890";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
This is a bug in MFMessageComposeViewController because why would they allow images to be inserted into one and not the other. I would insert an image but I'm not allowed to because I do not have enough reputation.

I have a link to my terms and conditions data and I want to show this data by reading it

How do I read data from an USL link, and display it on my textview? The URL link content contains only normal text
I am using:
NSString *userAgreementStringURL = [NSString stringWithFormat:#"%#/requestConfigurationData.php?ownerID=%#&view=userAgreement", serverURL, ownerID];
NSURL *userAgreementURL = [NSURL URLWithString:userAgreementStringURL];
NSURLRequest *userAgreementRequest = [NSURLRequest requestWithURL:userAgreementURL];
userAgreementData = [[NSMutableData alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
userAgreementConnection = [[NSURLConnection connectionWithRequest:userAgreementRequest delegate:self] retain];
[userAgreementTextView setText:[NSString stringWithContentsOfURL:#"http://medicinephone.com/dev2/visit/requestConfigurationData.php?ownerID=13&view=userAgreement" encoding:NSUTF8StringEncoding error:NULL]];
Show us your code. If you are trying what I think you are trying passing an array to text view's setText method won't work. You need to get the string from the array prior to that. If you array contains one word per array element you might want to try using componentsJoinedByString.
[myTextView setText:[NSString stringWithContentsOfURL:[NSURL URLWithString:#"http://apple.com" encoding:NSUTF8StringEncoding error:NULL]]];
one line of code, thank you apple.
Edit: forgot to make a NSURL from the string.