Leaves and UIWebView (2)

来源:互联网 发布:淘宝的评论怎么删除 编辑:程序博客网 时间:2024/05/08 16:36

 Messages 26 - 50 of 53 - Collapse all< Older  Newer >


   Varedis  View profile   More options Sep 2, 7:45 am
My soultion involves using CSS to cut up the file into columns so no 
javascript is used. 

However I worked with trying to implement javascript paginating for a 
while, there are a few opensource javascript readers on the internet 
that you can look at the code for and disect. 

Getting the font size I implemented at a point the code I used was: 

[self.webView stringByEvaluatingJavaScriptFromString:@"var who = 
document.createElement('div');" 
     "who.id = 'tem';" 
     "who.style.padding = '0px';" 
     "who.style.margin = '0px';" 
     "who.style.lineHeight = '1';" 
     "who.style.position = 'absolute';" 
     "who.style.visibility = 'hidden';" 
     "who.appendChild(document.createTextNode('M'));" 
         "document.getElementsByTagName('body')[0].appendChild(who);"]; 

    float mHeight = [[self.webView 
stringByEvaluatingJavaScriptFromString:@"document.getElementById('tem').off setHeight;"] 
intValue]; 

        NSLog(@"M HEIGHT: %f", mHeight); 

This will get the current eM size of the font and return it as pixels. 

On Sep 2, 9:36 am, "snehal.............." <jacksn...@gmail.com> wrote: 

- Show quoted text -

 

...

read more »


    Forward  
   
   snehal..............  View profile   More options Sep 2, 8:45 am

Hi Varedis, 

Thanks for your quick reply and thanks for sharing the code too . 

 I have implemented paging via java script and its working good :) not the 
way i want . Actually we need the bar in the bottom like the iBook have 
where a person can directly scroll and go and tht's basically a paging 
thing. Now i m working on the font size and the image sizes :) still no luck 
with a proper way . Do you have a idea how to do that i mean currently i am 
just going at that path and taking the image height and width which is like 
very much time consuming. 

And I just want your opinion on something like . I mean do you think the 
iBook is merging all the html files into a single one and making that paging 
possible for them I just need a opinion on this :) .Because how they are 
showing the page numbers and the things ? 

Sorry i mean i ask lots and lots of questions :) . 

On Thu, Sep 2, 2010 at 5:15 PM, Varedis <robert.scot...@btinternet.com>wrote: 

- Show quoted text -

 

...

read more »


    Forward  
   
   dBonates  View profile   More options Sep 2, 9:56 am
Hi all, 

Varedis, great work! I'm curious abou the results at end :) 

And about the question above, I dont think iBooks uses html at all... 
I seems to me that they use UITextInput and CoreText. I could be 
wrong, but with this aproach, rendering pages as images, they couldnt 
get that selection feature and any others related to texto 
manipulation. 

By the way, Im trying to figure how it can be done, I mean, write 
pages full of selectable texts on Leaves Views... 

Cheers :) 

On 2 set, 09:45, "snehal.............." <jacksn...@gmail.com> wrote: 

- Show quoted text -

 

...

read more »


    Forward  
   
   snehal..............  View profile   More options Sep 2, 11:15 am

Hi Varedis, 

Finally I got a break through :) . And now i know how iBook must have been 
done :) . What i asked in the previous question is r8 . After completion of 
that thing i would like to share the code with you for the further 
processing of that with the rendering part and some other features which i 
would like to do .. Finally i m happy :) ... I will post the video of it 
soon :) . 

- Show quoted text -

 

...

read more »


    Forward  
   
   Varedis  View profile   More options Sep 2, 11:30 am
Hi Snehal, 

I look forward to seeing what you have achieved. 

dBonates: 

While I haven't extensively tested the subject of text selection I did 
briefly brainstorm it, without any tested I would say that the 
interactionLocked method needs to be looked at and utilized in Leaves 

On Sep 2, 4:15 pm, "snehal.............." <jacksn...@gmail.com> wrote: 

- Show quoted text -

 

...

read more »


    Forward  
   
   ashraf  View profile   More options Sep 4, 6:50 am

I also tried the css3 multi columns support, I started my tests on 
Safari and it worked like a charm. I was disappointed when I moved my 
code to iPad, it seems that mobile safari does not support the columns 
module fully. 

If you can guide me a little bit on this, I will esteem it a favor. 

The second approach is to fill a div with the content word by word 
until scrollHieght equals the offsetHieght. 

NSArray * contentArray = [chapter.Content 
componentsSeparatedByString:@" "]; 

<script language="JavaScript" type="text/javascript"> 

                var content = ""; 

                        function setContent(){ 

                                theObj = document.getElementById("foo"); 
                                theObj.innerHTML = content; 
                                if(theObj.offsetHeight == theObj.scrollHeight) 
                                        return "OK"; 

                                return "NO"; 
                        } 
 </script> 

still this way is slow and it is not the most efficient. 
Now I paginate the content for each font size and store the positions 
in a database. 
Still I want a dynamic solution. 

----------------------------------------- 
On Sep 2, 2:45 pm, Varedis <robert.scot...@btinternet.com> wrote: 

- Show quoted text -

 

...

read more »


    Forward  
   
   Varedis  View profile   More options Sep 8, 8:38 am
Mobile Safari does support multi columns, however it needs a little 
helping hand to make it think in the right way. 

The Css File: 

html { 
    width:100%;   // Do Not Change 
    height: 480px;  // Height of Screen, could be set to 100% maybe 
    margin: 0px; 
    padding: 0px; 
    font-size:16px; 



body { 
    margin: 0px; 
    padding: 0px; 


#viewer { 
    width: 320px;  // SCREEN WIDTH 
    height: 480px; // SCREEN HEIGHT 


#book { 
    width: 630px;  //DOUBLE SCREEN WIDTH MINUS WHATEVER MARGIN YOU 
WANT - THIS IS THE KEY 
    height:470px; //SCREEN HEIGHT MINUS MARGIN 
    padding:5px; 
    -webkit-column-width:300px; 
    -webkit-column-gap:10px; 
    text-align:justify; 
    padding-right: 10px; 

 



Your content will need to be wrapped by the two divs like so: 

<div id="viewer"> 
<div id="book"> 
....Content.... 
</div> 
</div> 

Then everything should work. 

The width of the book div is the key to forcing the content to 
transfer into columns correctly


    Forward  
   
   ashraf  View profile   More options Sep 8, 1:25 pm
Many thanks for sharing this piece of innovation, I really liked it. 

How did you solved the problem of memory consumption? 

Although I use background rendering, still RenderPageAtIndex method 
eats the memory in seconds, the NSAutoRealsePool trick didn't work 
here. 

Thank you again 

On Sep 8, 3:38 pm, Varedis <robert.scot...@btinternet.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Varedis  View profile   More options Sep 14, 8:42 am
Haven't had a problem with memory consumption here 

On Sep 8, 6:25 pm, ashraf <ashrafan...@me.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Mohammed Al-Ashraf Osman  View profile   More options Sep 14, 1:23 pm

Thanks for your answer, the problem which I am talking about is this: 

 

>>> Hi Max! 

>>> This is because application use all memory :( 

>>> I fixed this bug locally (you should release all hidden layers) but by now I'm unable to do a commit :( 

>>> Just few days ;) 

>>> Salvatore 

Please tell us which hidden layer must be released in LeavesView class. 
The sooner is better. 

Sent from my iPad 

On Sep 14, 2010, at 3:42 PM, Varedis <robert.scot...@btinternet.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Varedis  View profile   More options Sep 21, 4:39 am
Been trying to set up a GitHub account but it won't let me push any 
changes into it, if anyone could help me sort this out that would be 
awesome. 

For now here is the complied source for this 

http://www.robsanimate-studio.co.uk/UIWebView_leaves.zip 

Warning: As it stands this will not work with any other type of 
rendering like the pdf or image rendering seen in the normal leaves. 
There may be a slight bug on the Simulator when you change the text 
size and part of the screen retains the old text size. This seems to 
be just a simulator bug and from my testing it works fine on the 
device.


    Forward  
   
   Madhu Bhilwadi  View profile   More options Sep 21, 5:31 am

this app is crashing. and one more thing , i observed is , 
  i edited the xhtml file and inserted some hyperlinked content with Tag <a 
href> ---- </a>. 

it highlighted that text, but after clicking that is is not responding to 
following method. 
May i know y ? 

- (BOOL)webView:(UIWebView*)webView 
shouldStartLoadWithRequest:(NSURLRequest*)request 
navigationType:(UIWebViewNavigationType)navigationType { 

    if(navigationType == UIWebViewNavigationTypeLinkClicked) { 
        NSLog(@" link clicked"); 

            [myWebView stopLoading]; 

            return YES; 
      } 

    return YES; 

 



On Tue, Sep 21, 2010 at 2:09 PM, Varedis <robert.scot...@btinternet.com>wrote: 

 

> Been trying to set up a GitHub account but it won't let me push any 
> changes into it, if anyone could help me sort this out that would be 
> awesome. 

> For now here is the complied source for this 

> http://www.robsanimate-studio.co.uk/UIWebView_leaves.zip 

> Warning: As it stands this will not work with any other type of 
> rendering like the pdf or image rendering seen in the normal leaves. 
> There may be a slight bug on the Simulator when you change the text 
> size and part of the screen retains the old text size. This seems to 
> be just a simulator bug and from my testing it works fine on the 
> device. 

-- 
This is my profile: 
http://www.google.com/profiles/madhu.bhilwadi88 

Madhu Bhilawadi 


    Forward  
   
   Varedis  View profile   More options Sep 21, 5:39 am
Can you give me anymore info on the crash? any errors or warnings? 
where exactly does it crash what is it logging in the console? 

The hyperlink problem is that all touches are passed to Leaves and not 
the UIWebView. You would have to find a way to build your touches to 
know what is a hyperlink touch and what is a page turn touch. 

On Sep 21, 10:31 am, Madhu Bhilwadi <bhilwadi.ma...@gmail.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Madhu Bhilwadi  View profile   More options Sep 21, 8:14 am

it works fine wen i am in debugging mode 
but it crashes if i run 

One more thing is , u are using xhtml file, is it possible for me to use pdf 
instead?? 

On Tue, Sep 21, 2010 at 3:09 PM, Varedis <robert.scot...@btinternet.com>wrote: 

 

- Show quoted text -

 

-- 
This is my profile: 
http://www.google.com/profiles/madhu.bhilwadi88 

Madhu Bhilawadi 


    Forward  
   
   Varedis  View profile   More options Sep 22, 9:09 am
Is it crashing on the device or the simulator? 

I haven't tried using a pdf in a webview before, if you want to try go 
ahead and let me know the results 

On Sep 21, 1:14 pm, Madhu Bhilwadi <bhilwadi.ma...@gmail.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Madhu Bhilwadi  View profile   More options Sep 22, 9:17 am

in simulatior 

On Wed, Sep 22, 2010 at 6:39 PM, Varedis <robert.scot...@btinternet.com>wrote:

 

- Show quoted text -

 

-- 
This is my profile: 
http://www.google.com/profiles/madhu.bhilwadi88 

Madhu Bhilawadi 


    Forward  
   
   Varedis  View profile   More options Sep 22, 9:25 am
Try adding: 

gpdfpass= [NSString stringWithFormat:@"The Colour of Magic"]; 

to the top of the init method in WebViewController just above where it 
hides the bottom bar. 

Thats the only thing I can think of that it is not getting, which is 
the name of the book. 

Also there are a couple of deprieciated statements throughout the code 

If you get warnings change: 

[[UIApplication sharedApplication] setStatusBarHidden:NO animate:YES]; 
[[UIApplication sharedApplication] setStatusBarHidden:YES 
animate:YES]; 

to 

[[UIApplication sharedApplication] setStatusBarHidden:NO 
withAnimation:YES]; 
[[UIApplication sharedApplication] setStatusBarHidden:YES 
withAnimation:YES]; 

On Sep 22, 2:17 pm, Madhu Bhilwadi <bhilwadi.ma...@gmail.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Madhu Bhilwadi  View profile   More options Sep 23, 12:33 am

ok thanq fir the good response :) 

I actually not using web view to display pdf, i have used 
http://github.com/ole/leaves/tree/twopages for my project 

 Now i want pdf internal URL to work 
How can i proceed , after clicking URL , how should i get the link? 

On Wed, Sep 22, 2010 at 6:55 PM, Varedis <robert.scot...@btinternet.com>wrote:

 

- Show quoted text -

 

-- 
This is my profile: 
http://www.google.com/profiles/madhu.bhilwadi88 

Madhu Bhilawadi 


    Forward  
   
   Tony  View profile   More options Sep 26, 11:43 am
Has the code been moved? This link doesn't work for me. Thanks 

On Sep 21, 1:39 am, Varedis <robert.scot...@btinternet.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Madhu Bhilwadi  View profile   More options Sep 27, 4:53 am

the link download source is there at the top 

 

- Show quoted text -

 

-- 
This is my profile: 
http://www.google.com/profiles/madhu.bhilwadi88 

Madhu Bhilawadi 


    Forward  
   
   wesam Taha  View profile   More options Oct 2, 11:14 am

the link is not working 

The page cannot be found 

The page you are looking for might have been removed, had its name 
changed, or is temporarily unavailable. 

 

> > http://www.robsanimate-studio.co.uk/UIWebView_leaves.zip 

On Sep 27, 12:53 pm, Madhu Bhilwadi <bhilwadi.ma...@gmail.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Daniel Bonates  View profile   More options Oct 5, 10:26 am
the host does really exist? Someone ghot the zip??? 

thanks in advance :) 

2010/10/2 wesam Taha <busb...@gmail.com>: 

 

- Show quoted text -

 

-- 
Daniel Bonates 
========================= 
msn: danielbona...@hotmail.com 

    Forward  
   
   Raj  View profile   More options Oct 14, 10:47 am
Varedis/Madhu, 

I'm working on similar webview issue. Can you please share the zip 
file? 

Appreciate your help, 

Thanks, 
Raj 
basav...@gmail.com 

On Oct 5, 10:26 am, Daniel Bonates <dbona...@gmail.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Varedis  View profile   More options Oct 20, 4:48 am
Hi Guys, 

I have reuploaded the file again, I have made a few changes and put 
some comments in so you know what bit does what, its not the cleanest 
code in the world but it gets the job done. 

What this code does: 

Renders Epub books to a UIWebView 
Paginates written content correctly 

What this does not do currently: 

This will not paginate images correctly 

Issues: 

None on the device 
Simulator has an issue if you are changing the text size on the second 
page but I can't see where that is coming from. 
The leaves code will not work with other forms of content like PDF or 
Images. 

I will not provide debugging tips for any other part of leaves as this 
is not my project, I will provide debugging for my UIWebView parts 
however. 

If you like my code I would appreciate any donation you can give for 
the hours I have put in to this: 

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=... 

On Oct 14, 3:47 pm, Raj <basav...@gmail.com> wrote: 

- Show quoted text -

 


    Forward  
   
   Varedis  View profile   More options Oct 20, 4:50 am
I forgot to put the link to the file in, that may help: 

http://www.robsanimate-studio.co.uk/leaves.zip 

On Oct 20, 9:48 am, Varedis <robert.scot...@btinternet.com> wrote: 

- Show quoted text -

原创粉丝点击