last day (266 days later) » 

5:51 AM
0
A: how to add text view and image view on different views

AkhilrajtrTry this, .... if (nil == controller.view.superview) { ..... CGRect frame = scrollView.frame; frame.origin.x = frame.size.width * page; frame.origin.y = 0; controller.view.frame = frame; //Add textview as subview to controller UITextView *textView = [[UITextView ...

 
no this is not working.textview is not added on the view.but whenever i chane the view bt scrolling this log thing is printed.
 
Did you add controller.view to scrollview anywhere?
 
yes i have added [controller.view addSubview:textview]
 
I think you are not adding controller.view to scrollView by [scrollView addSubview:controller.view]; after setting frame to it. Pls check the updated answer.
 
yes you were right i was missing this part of adding controller view to the scroll view.Now i'm not getting blank white color screen but a black color scroll view with the loader loading on it as if some data will be loaded but still i'm not getting the text view
 
5:51 AM
Try setting frame and backgroundColor to textView. Also set [controller.view bringSubViewToFront:textView];
 
for(int j=1;j<=k;j++) { [controller.view addSubview:_txtView]; _txtView.text = @"hello"; _txtView.frame = CGRectMake(80,190,170,280); _txtView.backgroundColor = [UIColor yellowColor]; //set tag to textView if needed [controller.view addSubview:_txtView]; _txtView.textColor = [UIColor orangeColor]; [scrollView addSubview:controller.view]; NSLog(@"string to txt===="); } still not working
 
create new object for UITextView for each controller view as in answer and try. Here you are using the same textView reference.
 
6:03 AM
hi
 
i am stuck up in this problem
 
create new object for UITextView for each controller view as in answer and try. Here you are using the same textView reference.
 
couldn't find anything working
 
use different object of textfield
instead of _txtView
 
6:05 AM
how
 
as in the answer
UITextView *textView = [[UITextView alloc] init];

textView.text = @"hello";

textView.frame = //set frame here

//set tag to textView if needed
[controller.view addSubView:textView];
 
i have done this thing
if (nil == controller.view.superview) {

CGRect frame = scrollView.frame;

frame.origin.x = frame.size.width * page;

frame.origin.y = 0;

controller.view.frame = frame;

for(int j=1;j<=k;j++)
{
[controller.view addSubview:txtView];
txtView.text = @"hello";

txtView.frame = CGRectMake(80,190,170,280);
txtView.backgroundColor = [UIColor yellowColor];

//set tag to textView if needed
[controller.view addSubview:txtView];
txtView.textColor = [UIColor orangeColor];
[scrollView addSubview:controller.view];
k is the number of controllers added
 
I think we don't need for(int j=1;j<=k;j++)
 
i have checked it without for loop also
 
if (nil == controller.view.superview) {

CGRect frame = scrollView.frame;

frame.origin.x = frame.size.width * page;

frame.origin.y = 0;

controller.view.frame = frame;

for(int j=1;j<=k;j++)
{
txtView.text = @"hello";

txtView.frame = CGRectMake(80,190,170,280);
txtView.backgroundColor = [UIColor yellowColor];

//set tag to textView if needed
[controller.view addSubview:txtView];
txtView.textColor = [UIColor orangeColor];
[scrollView addSubview:controller.view];
// [controller.view bringSubViewToFront:_txtView];
sry
pls ignore that
remove the for loop and init textfield UITextView *textView = [[UITextView alloc] init];, then set txtView.text = @"hello"; etc
i can't see any initialisation code for textview
 
6:14 AM
ok
let me try this
 
yes now i can see the text field on my controllers
thank u soo much
 
you are welcome
 
but now how can i add dyanamic text to the text view
txtView.text=[[_arrUrlLinks objectAtIndex:i] valueForKey:@"ARTICLE BODY"];
 
replace txtView.text = @"hello"; with [txtView setText:[Dic valueForKey:@"ARTICLE_BODY"]];
 
6:19 AM
this is what i want to display on my text view
 
[txtView setText:[Dic valueForKey:@"ARTICLE_BODY"]];
implemented this code but the textview goes blank
means no text is dispalyed
and i want different text on all textviews according to the data i m getting from Article body
hello??
u there?
 
check Dic
NSLog
 
yes i m getting the contents in the log
 
check the key
is that @"ARTICLE_BODY"?
 
6:28 AM
yes the key is this
i m getting the article null
NSMutableArray *array = [Dic objectForKey:@"ARTICLE_BODY"];
//_arrUrlLinks= [Dic objectForKey:@"ARTICLE_BODY"];
NSLog(@"article=== =%@",array);
wen i do this the article content is printed in log
 
so it is an array?
 
yes i m taking it not an array and printing it in log
*into an array
 
so set the objectAtIndex: from array to textview
i think the page number will the index
 
wen i was not using this scroll part:
[self._txtView setText:[Dic valueForKey:@"ARTICLE_BODY"]];
was working
 
can you show NSLog(@"article=== =%@",[Dic valueForKey:@"ARTICLE_BODY"]);
 
6:37 AM
"ARTICLE_BODY" = "\U0915\U093e\U092c\U0941\U0932/\U0928\U0908 \U0926\U093f\U0932\U094d\U0932\U0940 : \U0905\U092b\U0917\U093e\U0928\U093f\U0938\U094d\U0924\U093e\U0928 \U0915\U0947 \U0939\U0947\U0930\U093e\U0924 \U092a\U094d\U0930\U093e\U0902\U0924 \U092e\U0947\U0902 \U092d\U093e\U0930\U0924\U0940\U092f \U0935\U093e\U0923\U093f\U091c\U094d\U092f \U0926\U0942\U0924\U093e\U0935\U093e\U0938 \U092a\U0930 \U092d\U093e\U0930\U0940 \U0939\U0925\U093f\U092f\U093e\U0930\U094b\U0902 \U0938\U0947 \U0932\U0948\U0938 \U092c\U0902\U0926\U0942\U0915\U0927\U093e\U0930\U093f\U092f\U094b\U0902 \U0928\U0947 \
 
Try NSString *body = [Dic valueForKey:@"ARTICLE_BODY"]; textView.text = body;
if not working pls show the latest working code
 
ok
in _arrUrlLinks i have the links
 
from those links i want to load the contents of article body
 
okay
 
6:47 AM
in body also null is being printed
 
6:59 AM
i have done xml parsing in another class
hi
now i m getting the text in text view
but the same text in all the views
NSMutableArray *array = [Dic objectForKey:@"ARTICLE_BODY"];
body=[array objectAtIndex:i];
then i m getting this exception:body=[array objectAtIndex:i];
u there?
hello??
plz guide me
 
7:23 AM
hi
will back in 10 min
ok
u der?
 
7:49 AM
yes
 
may be objectForKey:@"ARTICLE_BODY" is not an array
are you parsing xml and set values to Dic ?
 
yes i m parsing the xml
storing those value in Dic
and then taking the contents of Dic in an array
but this is showing only the first index value of the array
 
so Dic is the first element of an array?
will back in 15 min
 
8:11 AM
contents of first article body is displayed in all the text views
 
8:24 AM
plz let me knw wen u r back
 
8:42 AM
hi
do you have different dic for each link in _arrUrlLinks?
 
no there is only one dictionary
 
so where the different articles are stored?
we have different controller view for each link in _arrUrlLinks ri8?
 
8:58 AM
yes
 
each controller view have corresponding articles ri8?
 
9:32 AM
yes ther should have
but right now it is only showing the text at index value 0 of the array
 
that may be because Dic is the 0'th element of the array
 
how can this thing be rectified
 
from where Dic get value?
from where you assigning value to Dic
 
-(void)DownLoadData:(NSString *)indexSelect
{
self._parserForNewsDetail = [afaqsParser getInstance];
[[afaqsParser getInstance] setCacheNeed:TRUE];
ab= [self._parserForNewsDetail parseWithUrl:[_arrUrlLinks objectAtIndex:[indexSelect integerValue]] UrlTypefor:nil];

NSLog(@"arrUrls--------- %d",[_arrUrlLinks count]);
//NSLog(@"ab--------- %d",[ab count]);






resultDic = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0];


NSLog(@"Detail Dic = %@",[resultDic description]);
 
problem may be resultDic = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0]; this line
here only first element is used
 
9:47 AM
but if i change it to some other index it returns out of beyonds
 
read objectForKey:@"items" to NSArray
NSArray *items = [[self._parserForNewsDetail getLinkAndIdDic] objectForKey:@"items"];
oh.. my mistake
resultDic is for one element in _arrUrlLinks ri8?
 
yes
other is other dictionary NSDictionary * Dic
which contains "Article Body"
 
then you must add each resultDic to an array
Add each resultDic to a mutable array at index = [indexSelect integerValue] of that array
let it be resultItemsArray
you can insert each resultDic using insertObject: atIndex: method of mutable array
 
10:08 AM
ok let me try this
 
and set text by selecting correct object from resultItemsArray
that will be a resultDic
and its valueForKey:@"ARTICLE_BODY" will be the text
the index may be the page number i think
 
10:26 AM
i am getting this exception:[__NSCFString objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x14d69c80
 
10:40 AM
before implementing scroll view my this code was working very fyn
-(void)SetValuesInUserInterface:(NSDictionary *)Dic
{

//self._imageView1 = [[ImageDownLoader alloc]initWithFrame:self._imageView1.frame];

self._imageView1.layer.cornerRadius = 4;
self._imageView1.clipsToBounds = YES;
//self._EventImageView = [[ImageDownLoader alloc] init];

self._imageView1.tag = 999;
NSURL *imgurl =[NSURL URLWithString:[[Dic valueForKey:@"image"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
self._imageView1.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:imgurl]];
 
10:51 AM
    NSURL *imgurl =[NSURL URLWithString:[[Dic valueForKey:@"image"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
   _imageview.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:imgurl]];
i am using this code to get the image
i image view is also blank
[controller.view addSubview:_imageview];
u there??
 
11:17 AM
helloo?
 
11:29 AM
hlo
 
what should i do
i have stuck up in this problem
 
11:41 AM
can you show the updated DownLoadData: method
also the method which invokes SetValuesInUserInterface: method
 
NSMutableArray *array = [Dic objectForKey:@"ARTICLE_BODY"];
//_arrUrlLinks= [Dic objectForKey:@"ARTICLE_BODY"];
NSLog(@"jaisairam=== =%@",array);

NSLog(@"jaisairam ji===.. =%@",_arrUrlLinks);

body = [Dic valueForKey:@"ARTICLE_BODY"];
headerstr=[Dic valueForKey:@"header"];
imgstr=[Dic valueForKey:@"image"];
using this in setValuesInInterface
i'm getting the contents
header
article body
on the view
 
DownLoadData: method?
 
-(void)DownLoadData:(NSString *)indexSelect
{
self._parserForNewsDetail = [afaqsParser getInstance];
[[afaqsParser getInstance] setCacheNeed:TRUE];
ab= [self._parserForNewsDetail parseWithUrl:[_arrUrlLinks objectAtIndex:[indexSelect integerValue]] UrlTypefor:nil];

NSLog(@"arrUrls--------- %d",[_arrUrlLinks count]);
//NSLog(@"ab--------- %d",[ab count]);

// for (k =0; k<=[_arrUrlLinks count]-1; k++)
// {
// NSString *currentelement = [_arrUrlLinks objectAtIndex:k];
// // UITextView *txtview;
 
by this method
resultDic = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0];
will replace resultDic each tym ri8?
 
yes
each tym the result will be updated
 
11:51 AM
is that we require?
or all resultDicts?
corresponding to indexSelect
 
we need the contents of resultDic
-(void)DownLoadData:(NSString *)indexSelect
{

sleep(1.0);
{
[[SharedUtilities getInstance]AddActivityIndicatorViewOnMainThread:self.view];
}


self._parserForNewsDetail = [afaqsParser getInstance];
[[afaqsParser getInstance] setCacheNeed:TRUE];
ab= [self._parserForNewsDetail parseWithUrl:[_arrUrlLinks objectAtIndex:[indexSelect integerValue]] UrlTypefor:nil];

NSLog(@"arrUrls--------- %d",[_arrUrlLinks count]);

resultDic = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0];
using this code i was able to load all the things i needed
but it was on the single view
i used swipe gesture in this
 
ok
lemme check the code
 
and with swipe the next contents were loaded on the view
now i want the next contents to be loaded on the next view
UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];

//add the your gestureRecognizer , where to detect the touch..
[_scrollView addGestureRecognizer:rightRecognizer];

UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{



self._scrollView.contentSize = CGSizeMake(self._scrollView.frame.size.width * [_arrUrlLinks count], self._scrollView.frame.size.height);

self._scrollView.contentOffset=CGPointMake (self._scrollView.frame.size.width, 0);

[self btnPreviousClick];




}


- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
NSLog(@"leftSwipeHandle");
[self btnNextClick];



self._scrollView.contentSize = CGSizeMake(self._scrollView.frame.size.width * [_arrUrlLinks count], self._scrollView.frame.size.height);
 
ok
hi
 
yes
 
12:08 PM
in -(void)DownLoadData:(NSString *)indexSelect
resultDic = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0];
NSDictionary *itemDict = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0];
[self.resultDicArray insertObject:itemDict atIndex:[indexSelect integerValue]];
add this
create a NSMutableArray * resultDicArray
as property
and alloc init in viewDidLoad
 
and in DownLoadData:
check
NSDictionary *dict = [self.resultDicArray objectAtIndex:[indexSelect integerValue]
if (!dict)
do the data fetch and parse
else
assign resultDic = dic
and do
[self performSelectorOnMainThread:@selector(SetValuesInUserInterface:) withObject: resultDic waitUntilDone:NO];

[[SharedUtilities getInstance]RemoveActivityIndicatorView];
 
-(void)DownLoadData:(NSString *)indexSelect
{
NSDictionary *dict = [self.resultDicArray objectAtIndex:[indexSelect integerValue]];
if (!dict) {
sleep(1.0);
{
[[SharedUtilities getInstance]AddActivityIndicatorViewOnMainThread:self.view];
}


self._parserForNewsDetail = [afaqsParser getInstance];
[[afaqsParser getInstance] setCacheNeed:TRUE];
ab= [self._parserForNewsDetail parseWithUrl:[_arrUrlLinks objectAtIndex:[indexSelect integerValue]] UrlTypefor:nil];

NSLog(@"arrUrls--------- %d",[_arrUrlLinks count]);
this is how it will look like
u der???
 
yes
was implementing that code
 
ohk..
 
12:23 PM
u r helping a lot
thanks for dat
no succes
 
hey np
oh..
:(
 
the result is still the same
 
actually what happens now
 
i hope the same view is not getting loaded every tym
the same contents on the textview
 
if it not a problem can you share the .h and .m
 
12:25 PM
ok
 
does other contents changing?
 
no every thing is same
 
does the image changing
 
image is not visible
is there any problem in parsing the data
that onlt first content is getting loaded
 
[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]
log it
and check whether it is same or not
 
12:29 PM
.h file
#import <UIKit/UIKit.h>
#import "MyViewController.h"
#import "afaqsParser.h"
#import "ImageDownLoader.h"


@interface textview : UIViewController
{
UIPageControl *pageControl;
NSMutableArray *viewControllers;

// To be used when scrolls originate from the UIPageControl
BOOL pageControlUsed;
MyViewController *controller;
NSDictionary *resultDic;
NSMutableArray *ab;
UIImageView *_imageview;
UITextView *txtView;
NSInteger count;
// NSDictionary *Dic;
NSMutableDictionary *elementryDict1;
int k,i;
NSString *body ;
 
ok
one thing off the topic
 
wat?
 
about naming convention of classes
it should start with capital letter
:)
 
just mentioned
ok
where is .m?
 
12:34 PM
-(void)DownLoadData:(NSString *)indexSelect
{
NSDictionary *dict = [self.resultDicArray objectAtIndex:[indexSelect integerValue]];
if (!dict) {
sleep(1.0);
{
// [[SharedUtilities getInstance]AddActivityIndicatorViewOnMainThread:self.view];
}


self._parserForNewsDetail = [afaqsParser getInstance];
[[afaqsParser getInstance] setCacheNeed:TRUE];
ab= [self._parserForNewsDetail parseWithUrl:[_arrUrlLinks objectAtIndex:[indexSelect integerValue]] UrlTypefor:nil];

NSLog(@"arrUrls--------- %d",[_arrUrlLinks count]);
in DownloadData i m only downloading the contents of current page
 
do i need to separately download next and previos data
 
it it different for different id's?
no
 
then
wats the problem
 
lemme check
 
12:38 PM
ok
 
yes
 
here you were calling [self DownLoadData:resultDic]; only once
in viewDidLoad
 
yes
 
so data is fetched only ince?
*once?
 
12:44 PM
ok
so should i go for for loop
to call download dat
data
for every array count
 
not a loop
 
then
 
when move to next view in scrollview
new data should be fetched ri8?
 
yes
 
and same data need not fetched multiple tym
 
12:46 PM
yes
 
dats y i suggested to use array for storing fetched data
 
plz tell me the solution
 
in - (void)scrollViewDidScroll:(UIScrollView *)sender
we have page
 
yes
 
call [self DownLoadData:page];
update the method by
-(void)DownLoadData:(NSInteger )indexSelect
and
also
 
12:50 PM
it gives implicit conversion of int to NSstring
 
int page to NSInteger page
replace [indexSelect integerValue] to indexSelect
wer?
in viewDidLoad
[self DownLoadData:0];
 
NSInteger * page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
nsinteger incompatiblw with double
 
remove *
NSInteger page
 
done this also
but nothing changes
 
1:07 PM
-(void)downLoadData:(NSInteger )indexSelect
{
NSDictionary *dict = [self.resultDicArray objectAtIndex:indexSelect];
if (!dict) {
sleep(1.0);
{
// [[SharedUtilities getInstance]AddActivityIndicatorViewOnMainThread:self.view];
}


self._parserForNewsDetail = [afaqsParser getInstance];
[[afaqsParser getInstance] setCacheNeed:TRUE];
ab= [self._parserForNewsDetail parseWithUrl:[_arrUrlLinks objectAtIndex:indexSelect] UrlTypefor:nil];

NSLog(@"arrUrls--------- %d",[_arrUrlLinks count]);

resultDic = [[[self._parserForNewsDetail getLinkAndIdDic] valueForKey:@"items"]objectAtIndex:0];
try now
u der?
tym to leave
 
yes
can we continue this on monday plz
 
sure
can you share the .h and .m file
in mail or anything?
 
how?
 
give me ur mail id
 
1:12 PM
akhilr46@gmail.com
and yours?
 
[textview SetValuesInUserInterface:]: unrecognized selector sent to instance 0x1669e9b0
pooja.bdcs@gmail.com
this is what i m getting
 
the line?
 
[662:60b] -[textview SetValuesInUserInterface:]: unrecognized selector sent to instance 0x1669e9b0
 
lets continue on monday pls
 
sure
thank u so much
 
1:15 PM
No problem
c u
 
:)
do snd the classes
 
bye
 
bye
 

  last day (266 days later) »