Showing posts with label ipad. Show all posts
Showing posts with label ipad. Show all posts

Thursday, October 4, 2018

iPad website JPGs appear very pixelated

Leave a Comment

Our website appears fine on a Mac. However, on an iPad, the home page slider images appear very very pixelated.

I've had a look at this article and changed the JPGs to progressive, and cleared the server cache, and the iPad Safari cache, yet the issue remains.

Help appreciated.

For the record, the 4 slider images are around 1100 - 1500 pixels wide:

2 Answers

Answers 1

From this answer, using background-attachment: fixed with background-size: cover causes issues on most mobile browsers. You can try using background-attachment: scroll. This won't give your desired effect, but you'll see the images at least. You could use a media-query or two to limit it to devices that are tablets or phones by using @media screen and (max-device-width: 1024px){}

OR

You can use background-position: scroll and include some javascript that will keep the image at the scrolled position (keeping it at the top of the window): DEMO

Answers 2

Maybe try to convert the image to a PNG or SVG and see if this helps. If you have a graphic designer have him do this or use one of the image converters on the web. JPEGs are compressed each time they're saved and this is a lossy compression so the image will artifact giving the pixelated look you're describing. If this solves the problem then you know it was a problem with the image itself. If it still appears pixelated then this may be a problem with the Ipad instead. I would then see if you can get a developer to set up an emulator for a different Ipad device, with Genymotion or with the built in emulator that comes with Android Studio, and visit your site on the emulator and see if the problem still persists. Hopefully this helps!

Read More

Thursday, June 21, 2018

Touch events only firing “once” during scroll in Mobile Safari on Ipad ios 11.4

Leave a Comment

While scrolling in mobile safari the first touchstart, touchmove, and touchend events are fired, however, if you're still scrolling additional touch events are not fired.

For my application this is problematic because a user can stop the scroll with their finger and I can't tell if there is a finger down. When a finger is down you can't set scrollTop of the window or rather you can set it, and it changes, but the window doesn't scroll. When the user moves their finger again it starts scrolling not from where I set the scrollTop but to whether their finger was put down.

Please no comments on why I want to change the scrollTop of the window; let's just accept that as an a priority requirement. Any thoughts for how to detect if there is a finger down?

0 Answers

Read More

Wednesday, February 21, 2018

SpriteKit screen width not measuring properly

Leave a Comment

I have this Sprite Kit game that passes some balls across the screen and the user has to tap them. If the user misses a ball and it goes off the screen then they lose.

The game works perfect when testing it on my iPhone but when I run it on my iPad it doesn't work as it's supposed to. It also doesn't work on iPhone X simulator. When the game first starts up it goes to the Start Scene, but when the user clicks "Start Game" it goes to the Game Scene and then automatically cuts to the game over scene without spawning any balls. After I hit "Play again" it will spawn the balls as it should but the measurements of detecting if the balls are out of bounds are not correct (which they are when testing on my iPhone 8 Plus).

Here are the areas where I think the problem may be coming. This is where the widths for things come from.

EnumerateChildNodes function to remove the balls once of the scene:

func searchChildNodes() {     self.enumerateChildNodes(withName: "BALL") { (node: SKNode, nil) in         if node.position.x < -25 || node.position.x > self.size.width + 25 {             print("balls Out")             node.removeFromParent()             let transition = SKTransition.fade(withDuration: 1)             self.gameScene = SKScene(fileNamed: "GameOverScene")             self.gameScene.scaleMode = .aspectFit             self.view?.presentScene(self.gameScene, transition: transition)         }     } } 

Specifically in the if statement:

if node.position.x < -25 || node.position.x > self.size.width + 25 

If remove the part after the || operator then the game lets the balls do what they are supposed, only without detecting if the are out of bounds on the right side of the screen.

Update

Here is the code that sets the position of the balls when they are spawned:

if ballDirection == "right" {     player?.position.x = 0     moveRight() } else {     player?.position.x = (self.scene!.frame.size.height)     moveLeft() } 

0 Answers

Read More

Wednesday, January 24, 2018

What do I use instead of two multiselect boxes in html so works on Phone/Ipad

Leave a Comment

In my HTML UI I wanted users to be able to select multiple countries, because there are far too many countries to allow the complete list to be displayed I initiate the HTML page so it has two lists: The second list has just those that have been selected, the first contain all countries (except ones already selected and add to the 2nd list), the user transfer between these two lists using an Add and Remove button

I display 15 rows for each select box by setting size attribute.

<tr>     <td>         <select id="preferred_countries_all" size="15" style="width:200px" multiple="multiple">             <option value=" AF">Afghanistan</option>             <option value="AX">Åland Islands</option>             <option value="AL">Albania</option>             <option value="DZ">Algeria</option>             <option value="AS">American Samoa</option>             <option value="AD">Andorra</option>             <option value="AO">Angola</option>             <option value="AI">Anguilla</option>             <option value="AQ">Antarctica</option>             <option value="AG">Antigua and Barbuda</option>             <option value="AR">Argentina</option>             <option value="AM">Armenia</option>             <option value="AW">Aruba</option>             <option value="AU">Australia</option>             <option value="AT">Austria</option>             <option value="AZ">Azerbaijan</option>             <option value="BS">Bahamas</option>             <option value="BH">Bahrain</option>..         </select>     </td>     <td>         <button style="width:100px" type="button" id="preferred_countries_add" onclick="add_preferred_countries();">         Add         </button>         <br>         <button style="width:100px" type="button" id="preferred_countries_remove" onclick="remove_preferred_countries();">         Remove         </button>     </td>     <td>         <select id="preferred_countries_selected" name="preferred_countries_selected" size="15" style="width:200px" multiple="multiple">         </select>     </td> </tr> 

However when I view on an iPad or Phone it only displays one row so you have to click to even see what has already been selected so it no longer works. I can understand why it might do this since space is limited on these devices, and perhaps my use of two select boxes for one option is non-standard but this doesn't work for me as a UI.

What do I use instead of two multiselect boxes in HTM: so works on Android phone or iPad as well as desktop

I had an idea of having one select box that the user could select additional countries, and a disabled text field that shows what has already been selected which is updated as user selects more countries, but how would they unselect values, what is the standard way to do this ?

Edit This is what I have so far

<tr>                             <td>                                 <label title="Potential Releases from these countries get their score boosted">                                     Preferred Release Countries                                 </label>                             </td>                             <td>                                 <input disabled="disabled" name="preferredCountries" id="preferredCountries" type="text" value="" class="readonlytextinfo">                             </td>                         </tr>                         <tr>                             <td class="indentedmultiselect" colspan="2">                                 <select id="preferred_countries_select" name="preferred_countries_select" multiple="multiple" onchange="getSelectValues(preferred_countries_select, preferredCountries)">                                     <option value=" AF">Afghanistan</option><option value="ZW">Zimbabwe</option>                                 </select>                             </td>                         </tr>  <script> function getSelectValues(select, readonlylist) {   var result = [];   var options = select && select.options;   var opt;    for (var i=0, iLen=options.length; i<iLen; i++) {     opt = options[i];      if (opt.selected) {       result.push(opt.text);     }   }   readonlylist.value =result.toString();   if(readonlylist.value.length>230)   {     readonlylist.value=readonlylist.value.substring(0,230) + '...';   }   return result; } </script> 

3 Answers

Answers 1

How each solution works on mobile you have to test yourself. In the chrome dev tools (f12) you can simulate mobile but in the end nothing beats a real phone. How most mobile jquery components work is by acting on a real select item by hiding it and showing a different DOM, updating the select in the background, thereby making it compatible with forms or other code expecting a select. Some overlay the original to get the proper mobile select response but a different view.

Answers 2

What you are asking for cannot be done natively with select boxes. The Mobile browsers will do as they please. I suggest you take a good google for free good components that solve your problem instead.

Such as:

or other depending on your choice of library/framework. if you give us more information on you library stack we might guide you better.

Answers 3

You could do this with two lists of checkboxes. It's much easier to style that way, and you have pretty much the same amount of control.

Here's a basic working example: https://codepen.io/niorad/pen/wpbjLj

<ul id="list1">   <li><input type="checkbox" name="1">Item 1</li>   <li><input type="checkbox" name="2">Item 2</li>   <li><input type="checkbox" name="3">Item 3</li> </ul>  <ul id="list2">   <li><input type="checkbox" name="4">Item 4</li>   <li><input type="checkbox" name="5">Item 5</li>   <li><input type="checkbox" name="6">Item 6</li> </ul>  <button id="button">Move</button> 

const button = document.getElementById('button');  button.addEventListener('click', () => {    const list1 = document.getElementById('list1');   const list2 = document.getElementById('list2');    const checkedFrom1 = list1.querySelectorAll('input:checked');   const checkedFrom2 = list2.querySelectorAll('input:checked');    checkedFrom1.forEach(item => {     item.checked = false;     list2.appendChild(item.parentNode);   })   checkedFrom2.forEach(item => {     item.checked = false;     list1.appendChild(item.parentNode);   }) }) 
Read More

Monday, October 30, 2017

How load PHP website on the iPad simulator or device?

Leave a Comment

I have one .php web site and I want to put it in iPad application "web application".

I mean create UIWebView and load files in WebView, so my First question is, is it possible to create this webApp and can I run it on Xcode simulator?

What do I need for implementing this application (Apache, MySQL) inside ipad outside?

Basically I want to have all my .php class inside of app and run it via iPad app, it means that if I hadn't any internet I can run the application.

Since I want to run it in both iPad and XCode simulator.

Would you please give me some hints for implement this application?

4 Answers

Answers 1

A few points you need to think about:

  • App Store Approval - if you intend to market this app (i.e it's not for jailbroken devices via Cydia, or an in-house corporate app) then you will most likely run in to issues with the approval process.*

    1. You're intending to bundle in a scripting language with your application. Now this may not be an issue depending on whether or not this is exposed to the end-user; but you do run the risk of Apple finding out and pulling the plug.

    2. The alternative to bundling in a scripting language (PHP in your case) is going to be loading the code off of an external server. This is a no-no straight away, as Apple requires your application to have functionality offline - or atleast they did. Where this leaves all the Social Networking and other network-dependant apps... Well, I guess there are exceptions!

  • Device Performance - you're essentially intending to run a small web server on a mobile device; a tablet in this case. This could be very resource intensive, so is probably not wise. I personally wouldn't want my battery being drained because someone has decided that they want to bundle in a web server with their application.

Your implementation idea itself is sound, in the respect of using a UIWebView. You should probably check out the Apache Cordova/PhoneGap framework, and that should satisfy your needs and provide an off-the-shelf way of packaging up your web app. If you do need custom functionality then it's worth looking at anyway; plugins are relatively easy to develop, there's a wide range available already and the plans for cordova now are to allow developers to implement it into native applications. (Say, if only one view requires PhoneGap functionality etc)

Personally, I fail to see what requires PHP that can not be done via HTML5 and PhoneGap. There are storage options available, SQL options, you're using web technologies so can easily query external web services. It's also a lot safer with regards to app approval - as it's tried and tested; there are many applications build using such solutions already in the store.

I think you need a serious re-think. Otherwise, perhaps you could post some more details?

Answers 2

A simple google search pulled up this free framework: http://www.ipfaces.org/

I've never used to before, but it might do what you need.

Answers 3

Not sure what exactly you need. PHP is a server-side language. Do you want to run a server on your iPad? You can develop PHP applications on a proper desktop/laptop and then view them on iPad Safari browser over Wifi.

Otherwise you can install LightHTTPd server, PHP libraries, MySQLi, CURL and all from Cydia app store on a jailbroken iOS device to get a full environment. For Android there is this app PAW server available which can run an Apache server in such devices.

Answers 4

If you just want to check your website is working fine on small devices, or you want to check responsiveness of your website. Go to:Ipad Peek and run your website on given devices/simulators using url.

Read More

Wednesday, August 9, 2017

How to programmatically scroll window on iPad?

Leave a Comment

My application includes several features that programmatically scroll to particular elements on a page. Unfortunately, it's not working on Safari/iPad. I have tried the following methods of scrolling:

window.scroll(0, y);  window.scrollTo(0, y);  $(window).scrollTop(y);  $('html, body').animate({     scrollTop: y }); 

Is it simply not possible to programmatically scroll the window on Safari/iPad, or am I just doing it incorrectly? All of these methods worked for all browsers I tested on the PC.

4 Answers

Answers 1

Have you tried any libraries? http://iscrolljs.com/ looks promising, but I cannot test (no iOS device).

  • Granular control over the scroll position, even during momentum. You can always get and set the x,y coordinates of the scroller.
  • Out of the box multi-platform support. From older Android devices to the latest iPhone, from Chrome to Internet Explorer.

Answers 2

I haven't found a way to scroll the window programmatically on iPad. One possible workaround is to wrap the page content in a fixed div container, and to scroll it by changing the div's scrollTop property. You can see that method in this codepen. I tested it successfully on iPad with Safari and Chrome, and on Windows with Firefox, Chrome and IE11.

HTML

<div id="container">     <div class="div1"></div>     <div class="div2"></div>     <div class="div3"></div>     ... </div> 

CSS

div#container {     position: fixed;     left: 0;     top: 0;     width: 100%;     height: 100%;     overflow-y: auto; } div {     height: 100px; } .div1 {     background-color: red; } .div2 {     background-color: green; } .div3 {     background-color: yellow; } 

Javascript

var container = document.getElementById("container"); setInterval(function() {     container.scrollTop += 1; }, 20); 

Answers 3

Its working fine for me on safari and iPad:

$('html, body').animate({         scrollTop: 0  }, 1000); 

Not sure but you can try it by giving some scroll animation timings in milliseconds.

Answers 4

i am using following code of jquery and it work for every browser (i dont user IE :) )

  $("html,body").animate({     scrollTop: 0 }, "slow"); 

Cross-browser scroll to top:

    if($('body').scrollTop()>0){         $('body').scrollTop(0);         //Chrome,Safari     }else{         if($('html').scrollTop()>0){    //IE, FF             $('html').scrollTop(0);         }     }  

Cross-browser a div with id = test_id:

    if($('body').scrollTop()>$('#test_id').offset().top){         $('body').scrollTop($('#test_id').offset().top);         //Chrome,Safari     }else{         if($('html').scrollTop()>$('#test_id').offset().top){    //IE, FF             $('html').scrollTop($('#test_id').offset().top);         }     }  
Read More

Wednesday, August 2, 2017

Position fixed elements jump around when loading or redirecting iframe (iPad only)

Leave a Comment

To see the problem clearly. Please take a look on the following youtube video. https://youtu.be/71TvKDInmSY
or try the widget on this site (iPad) https://naiise.com
Note: The site in video is different from the site above since the owner doesn't wanna use the widget anymore before the problem is fixed. But they are having the same problem.

1 Answers

Answers 1

The problem is caused by the translate3d transformation that you apply on the iframe;

-webkit-transform: translate3d(0, 0, 0); 

There is a well known problem in which translate3d causes position:fixed elements to behave like position:absolute in certain webkit browsers, such as those on iOS, as well as certain desktop versions of chrome.

Here is a demo which demonstrates the bug in action:

html,  body {      width:100%;      height:100%;      margin:0;      padding:0;      transform: translate3d(0, 0, 0);  }    #nav{      width:100%;      height:10%;      position:fixed;      top:0;      left:0;      background-color:red;  }    #content {      width:100%;      height:500%;  }
<!DOCTYPE html>  <html>   <body>    <nav id="nav">    </nav>    <main id="content">    </main>   </body>  </html>

In the demo, the red nav should be visible even after scrolling down. Depending on your browser, this may or may not work properly as is. Removing the problematic -webkit-transform: translate3d(0, 0, 0); style makes it work properly across all browsers.

This bug occurs due to the transform creating a new coordinate system, causing the position:fixed element to become affixed to the transformed element instead of the viewport.

I myself came across this bug while trying to smooth out transitions on iOS, and created a post about it here. More information can be found on this thread which I have also linked to in my own post.

The only surefire fix I know of is to remove the problematic translate3d style. If it is necessary, for example in order to coax iOS into enabling hardware acceleration (which is what I needed it for), then try applying it to different elements, either parents (body, html), or children of the iframe holder. I found that applying it to a completely unrelated element gave me the desired result.

There are also several case-specific workarounds and fixes in the thread I have linked to. One of those might do the trick.

It is a pretty nasty bug to track down. Took me a while to find it on my own page.

Best of luck.

Read More

Sunday, July 30, 2017

Default UICollectionView layout not respecting iPad split screen

Leave a Comment

My layout when on split screen is not respecting the width of the split screen.

My custom view is respecting it(the black bar at the top) but anything using autolayout is not respecting the width.

I am handling rotation using

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { 

Is there a helper method for handling split view? Do I handle it in layoutSubview? I would have expected the UICollectionView to handle this for us.

In viewWillTransition I use

  guard let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else {             return         }    flowLayout.invalidateLayout() 

enter image description here

1 Answers

Answers 1

I assume by "default" layout you mean a UICollectionViewFlowLayout. It looks like the itemSize width is bigger then the width of the view. Try adding a check in collectionView:layout:sizeForItemAtIndexPath: to make sure that the width is less than or equal to the collection's width.

Read More

Tuesday, July 25, 2017

How to set background color to UILabel text only

Leave a Comment

I'm working the App where i need to set the label like attached image. Please let me know if anyone have any idea?enter image description here

7 Answers

Answers 1

If using an attributed string with a background color on the string doesn't work then you might need to create 2 separate labels with space between them and set the background color on each.

Answers 2

May be you need some space with that background color where text has ended. I have solved this problem in my own tricks. Add some comma or point to separate the string. Then apply this to the string. No extra label need to create.

  NSArray *aArray = [@" Font Size  .k" componentsSeparatedByString:@".k"];  NSMutableAttributedString *fulltext=[[NSMutableAttributedString alloc] initWithString:@""];  NSMutableAttributedString *title1=[[NSMutableAttributedString alloc] initWithString:[aArray objectAtIndex:0]]; NSMutableAttributedString *title2=[[NSMutableAttributedString alloc] initWithString:[aArray objectAtIndex:1]];  //[title1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255.0/255.0 green:84.0/255.0 blue:49.0/255.0 alpha:1.0] range:NSMakeRange(0,title1.length)]; [title1 addAttribute:NSBackgroundColorAttributeName                value:[UIColor colorWithRed:255.0/255.0 green:84.0/255.0 blue:49.0/255.0 alpha:1.0]                range:NSMakeRange(0, title1.length)]; [title1 addAttribute:NSFontAttributeName                value:[UIFont boldSystemFontOfSize:(isIpad||isIPadPro)?19.0f:16.0f]                range:NSMakeRange(0,title1.length)];  [title2 addAttribute:NSForegroundColorAttributeName value:[UIColor clearColor] range:NSMakeRange(0,title2.length)]; [title2 addAttribute:NSBackgroundColorAttributeName                value:[UIColor clearColor]                range:NSMakeRange(0, title2.length)]; [title2 addAttribute:NSFontAttributeName                value:[UIFont boldSystemFontOfSize:(isIpad||isIPadPro)?19.0f:16.0f]                range:NSMakeRange(0,title2.length)];  [fulltext appendAttributedString:title1]; [fulltext appendAttributedString:title2];  self.textLabel.attributedText = fulltext; 

My output is like:

enter image description here

Now make the K's background (title2) clear, so you can get the spaces after text end with your space!

Answers 3

//setting dummy text to label self.lbLog.text=@"This is Simple Text With Red background Color";  //creating attributed string  NSMutableAttributedString *attribString = [[NSMutableAttributedString alloc] initWithString:self.lbLog.text];  //setting background color to attributed text [attribString addAttribute:NSBackgroundColorAttributeName           value:[UIColor redColor]           range:NSMakeRange(0, attribString.length)];  //setting attributed text to label self.lbLog.attributedText = attribString; 

Answers 4

lblText.backgroundColor=UIColor.red 

Answers 5

You can do like this

NSString *str1=@"What Does your friends really\n"; NSString *str2=@"Think of your spouce?"; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[str1 stringByAppendingString:str2]];  [attributedString addAttribute: NSBackgroundColorAttributeName value: [UIColor orangeColor] range: NSMakeRange(0, str1.length)]; [attributedString addAttribute: NSBackgroundColorAttributeName value: [UIColor redColor] range: NSMakeRange(str1.length, str2.length)];  NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:5]; [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [str2 length])]; lblTest.attributedText = attributedString ; 

Output of this Code:

Like This

Answers 6

You need to use separate label where you set background colour of the label if background colour of all label text is same for all text in label otherwise for different background colour for some of the text you need to use NSMutableAttributedString.

label.backgroundColor = [UIColor colorWithRed:29.0/255.0 green:135.0/255.0 blue:145.0/255.0 alpha:1.0]; 

Answers 7

Use two custom Label (or instead label use uiview as your background), One is for your background,set backgroundcolor as clear color and another label is for ur text set backgroundcolor as your desire color.

Read More

Friday, May 19, 2017

Exporting Video in full screen with AVAssetExportSession

Leave a Comment

i'm trying to do some animations to a video (after recording) and then export it. but before any animation i had the problem with the orientation which became landscape (without export it was portrait) and it is solved not but now i have problem with making it full screen.in iphone 6,7 plus its full screen how ever in ipad it is not.

here is my method :

func export(_ url : URL) {     let composition = AVMutableComposition()     let asset = AVURLAsset(url: url, options: nil)      let track =  asset.tracks(withMediaType : AVMediaTypeVideo)     let videoTrack:AVAssetTrack = track[0] as AVAssetTrack     let timerange = CMTimeRangeMake(kCMTimeZero, asset.duration)      let compositionVideoTrack:AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID())      do {         try compositionVideoTrack.insertTimeRange(timerange, of: videoTrack, at: kCMTimeZero)     } catch {         print(error)     }      let compositionAudioTrack:AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaTypeAudio, preferredTrackID: CMPersistentTrackID())      for audioTrack in asset.tracks(withMediaType: AVMediaTypeAudio) {         do {             try compositionAudioTrack.insertTimeRange(audioTrack.timeRange, of: audioTrack, at: kCMTimeZero)         } catch {             print(error)         }      }      let size = self.view.bounds.size      let videolayer = CALayer()     videolayer.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)      let parentlayer = CALayer()     parentlayer.frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)     parentlayer.addSublayer(videolayer)      let layercomposition = AVMutableVideoComposition()     layercomposition.frameDuration = CMTimeMake(1, 30)     layercomposition.renderSize = self.view.bounds.size     layercomposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videolayer, in: parentlayer)      let instruction = AVMutableVideoCompositionInstruction()      instruction.timeRange = CMTimeRangeMake(kCMTimeZero, asset.duration)      let videotrack = composition.tracks(withMediaType: AVMediaTypeVideo)[0] as AVAssetTrack     let layerinstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: videotrack)       let ratio = size.height / videoTrack.naturalSize.width      composition.naturalSize = videoTrack.naturalSize      layerinstruction.setTransform(videoTrack.preferredTransform.scaledBy(x: 0.645 , y: ratio).translatedBy(x: self.view.bounds.height, y: 0), at: kCMTimeZero)      instruction.layerInstructions = [layerinstruction]     layercomposition.instructions = [instruction]      let filePath = self.fileName()     let movieUrl = URL(fileURLWithPath: filePath)      guard let assetExport = AVAssetExportSession(asset: composition, presetName:AVAssetExportPresetHighestQuality) else {return}     assetExport.videoComposition = layercomposition     assetExport.outputFileType = AVFileTypeMPEG4     assetExport.outputURL = movieUrl     assetExport.exportAsynchronously(completionHandler: {         switch assetExport.status {         case .completed:             print("success")             let player = AVPlayer(url: movieUrl)             let playerViewController = AVPlayerViewController()             playerViewController.player = player             self.present(playerViewController, animated: true) {                 playerViewController.player!.play()             }             break         case .cancelled:             print("cancelled")             break         case .exporting:             print("exporting")             break         case .failed:             print("failed: \(String(describing: assetExport.error))")             break         case .unknown:             print("unknown")             break         case .waiting:             print("waiting")             break         }     }) } 

1 Answers

Answers 1

what fixed my problem was changing the scale factor and the translated amount. here is the code below :

    let size = self.view.bounds.size     let trackTransform = videoTrack.preferredTransform     let xScale = size.height / videoTrack.naturalSize.width     let yScale = size.width / videoTrack.naturalSize.height       let exportTransform = videoTrack.preferredTransform.translatedBy(x: trackTransform.ty * -1 , y: 0).scaledBy(x: xScale , y: yScale) 
Read More

Thursday, May 4, 2017

Swift SKSpiteNode position iPhone V iPad

Leave a Comment

I have positioned a node at the top left of the view in my app using the following code:

health = SKSpriteNode(color: .green, size: CGSize(width: progressValue, height: 50)) health.position = CGPoint(x: -self.frame.width / 2, y: self.frame.height / 2) 

This positions correctly in all iPhone simulators, ranging from 5 to 7 Plus.

However, it doesn't appear in any iPad simulator. I've set the position to midX and midY and it appeared fine just not with the code shown above which works perfectly for all iPhones.

What am I missing?

Is there a different way to position nodes on the view for an iPhone v iPad instead of using multiples of the view?

1 Answers

Answers 1

SOLVED:

The problem was that the scene scaleMode was set to .aspectFill which worked great for the iPhones just not for the iPads.

However .resizeFill worked perfectly so this is what I did.

if UIDevice.current.userInterfaceIdiom == .pad {                  scene.scaleMode = .resizeFill              }else{                  scene.scaleMode = .aspectFill               } 
Read More

Wednesday, January 25, 2017

Can we store NSURLRequest directly into Core Data?

Leave a Comment

I am developing iPad Application in which i need to create Multiple NSURLRequest. When is it fails I need to fire that URL request again.

I have three type (Create School, Create Floor and Create Rooms) of request which contain multiple parameters different create Request.

There is retrial method which can fire when there is internet available with same object which was created on first request.

So I was trying to create three Tables and I was trying to store all parameter with their status.

Is it possible to create Single Table with NSURLRequest irrespective of CREATE REQUEST?

3 Answers

Answers 1

You can probably just save the absoluteString of the NSURLRequest’s URL property. Or do they each have distinct timeouts or cache policies?

Answers 2

Core Data entities correspond to instances of NSManagedObject or a subclass of NSManagedObject, so you can't just save URL requests directly. What you could do is create an entity called something like SavedRequest that has a property representing the URL request-- and maybe some other details about the request (whatever other info you might need-- date, maybe?).

Since NSURLRequest conforms to NSCoding, you would create this property using the Core Data "transformable" type. Core Data would use NSCoding to automatically convert to/from NSData as needed. You would assign an NSURLRequest to the property and read them back, and Core Data would save them as NSData.

Given your description though, Core Data might not make sense. It sounds like you just want to save a list of URL requests and later read it back, and don't need the extra features Core Data would provide. It would be simpler to put your NSURLRequest objects in an array and then save that array to a file or to user defaults. You would convert to/from NSData yourself, but since you can use NSCoding that's easy.

To save the array you'd do something like this, assuming an array called myArray containing URL requests and a path in filePath:

BOOL success = [NSKeyedArchiver archiveRootObject:myArray toFile:filePath]; 

You'd get the array back using

NSArray *savedRequests = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; 

Answers 3

Yes that is possible, at least with Swift. With Swift you can access the Transformable property in CoreData. Using this property it is possible to put any kind of data in Core Data. That even without extra overhead.

See the excellent tutorial http://geekyviney.blogspot.nl/2015/02/transformable-binary-data-properties-in.html

Read More

Wednesday, June 29, 2016

Why can I not place Master and Detail view next to each other in UISplitViewController on the first run, but upon rotation it works?

1 comment

I have a split view controller that has a list of items on the left and a detail view on the right. Relevant code in AppDelegate:

let splitViewController = mainView.instantiateViewControllerWithIdentifier("initial") as! UISplitViewController            let rightNavController = splitViewController.viewControllers.last as! UINavigationController         let detailViewController = rightNavController.topViewController as! DetailsIpad          let leftNavController = splitViewController.viewControllers.first as! UINavigationController         let masterViewController = leftNavController.topViewController as! MainViewController          masterSplitViewController = masterViewController         detailSplitViewController = detailViewController          // Override point for customization after application launch.         let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController         navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()         splitViewController.delegate = self          self.window!.rootViewController = splitViewController 

When I first launch the app I see that the right part of the split screen takes up all of the screen:

enter image description here

If I rotate the screen, it becomes properly set (probably because both views are present on the screen):

enter image description here

When I set breakpoints everywhere, I see that the detail view on the right gets loaded before the master view on the left (list of items), despite not being called directly. I cannot change the order in which the views of the split screen are called. How can I fix this?

1 Answers

Answers 1

It's the default behavior of UISplitViewController. Have a close look at the following-

// An animatable property that controls how the primary view controller is hidden and displayed. A value of `UISplitViewControllerDisplayModeAutomatic` specifies the default behavior split view controller, which on an iPad, corresponds to an overlay mode in portrait and a side-by-side mode in landscape. @property (nonatomic) UISplitViewControllerDisplayMode preferredDisplayMode NS_AVAILABLE_IOS(8_0); 

Here's the key part from same definition-

on an iPad, corresponds to an overlay mode in portrait and a side-by-side mode in landscape.

Also, if you want to query the current state (display mode) of a UISplitViewController you should use this property-

// The actual current displayMode of the split view controller. This will never return `UISplitViewControllerDisplayModeAutomatic`. @property (nonatomic, readonly) UISplitViewControllerDisplayMode displayMode NS_AVAILABLE_IOS(8_0); 

And remember, you can't compare this with UISplitViewControllerDisplayModeAutomatic because-

This will never return UISplitViewControllerDisplayModeAutomatic.

My suggestion would be to set preferredDisplayMode to the value you want. In your case, it seems like you need the primary (master) to always be visible. So here's the proposed solution-

mySplitVC.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible 

Why it loads the secondary(detail) controller first?

As you can see, a UISplitViewController instance always needs a detail view no matter what displayMode it is in currently. So it's a good call to

  • load the detail view first.
  • load the primary view after (conditionally based on displayMode).

Hope this helps.

Read More

Friday, June 17, 2016

iPad Muting Web Audio API

Leave a Comment

I am unable to play any audio through Web Audio API on iPad. This is using the latest version of iOS (currently 9.3.2).

There are a number of threads online, the latest issue being autumn 2015. They suggest firing audio from a touchstart event to unlock iPad audio (or touchend while there were issues at that time). I have tried all of the suggested techniques and can't get touchstart, touchend or click to work. The audio is always muted on iPad.

Here is a bare-bones test I have set up (code below). None of the tests work on iPad for me. No problems on iPhone or other compatible browsers.

There is another test page here. None of those sounds play on three iPads tried.

Any insights or feedback would be much appreciated!

<!DOCTYPE html> <html> <head>     <title>Web Audio API - iPad Test</title>     <meta name="viewport" content="width=device-width, initial-scale=1">     <script src="./jquery-2.2.3.min.js"></script>     <style>         section { padding:10px; margin:0 0 10px; background:DarkSeaGreen }         a { cursor:pointer; display:block; background: DarkSeaGreen; padding:10px; margin:0 0 3px }     </style> </head> <body>     <script>         var app = {};         $(document).ready(function() {             // Do we have Web Audio API?             try {                 window.AudioContext = window.AudioContext || window.webkitAudioContext;                 audioContext = new AudioContext();             } catch (e) {                 alert('Web Audio API is not supported in this browser');             }             $('#loadClick').on('click',function(){load('./ipad_test.mp3')});             $('#playTouchEnd').on('touchend',play);             $('#playTouchStart').on('touchstart',play);             $('#playClick').on('click',play);             $('#unlockTouchEnd').on('touchend',unlock);             $('#unlockTouchStart').on('touchstart',unlock);             $('#unlockClick').on('click',unlock);         });         function unlock() {             // play empty buffer to unmute audio             var buffer = audioContext.createBuffer(1, 1, 22050);             var source = audioContext.createBufferSource();             source.audioContext = buffer;             source.connect(audioContext.destination);             source.start(0);             $('#messages').append('<p>Unlocked.</p>');         }         function load(file) {             if(app.loaded) {                 $('#messages').append('<p>Already loaded.</p>');                 return;             }             var request = new XMLHttpRequest();             request.open ('GET', file, true);             request.responseType = 'arraybuffer';             request.onload = function () {                 audioContext.decodeAudioData(                         request.response,                         function (buffer) {                             app.buffer = buffer;                             $('#messages').append('<p>Loaded.</p>');                             app.loaded = 1;                         },                         function(){alert('Load error.');}                 )             };             request.send();         }         function play() {             if(!app.loaded) {                 $('#messages').append('<p>Please load before playing.</p>');                 return;             }             var sourceNode = audioContext.createBufferSource();             sourceNode.buffer = app.buffer;             sourceNode.connect (audioContext.destination);             sourceNode.start(0);             $('#messages').append('<p>Playing.</p>');         }     </script>     <h1>Web Audio API Test</h1>     <p>Unlock should not be needed at all, but offers an alternative way to try and get the audio going. Load and then play should be all any compatible device needs. Refresh to start again.</p>     <a id="unlockTouchEnd">Unlock (touchend)</a>     <a id="unlockTouchStart">Unlock (touchstart)</a>     <a id="unlockClick">Unlock (click)</a>     <a id="loadClick" style="background:#c0c0c0">Load (click)</a>     <a id="playTouchEnd">Play Audio (touchend)</a>     <a id="playTouchStart">Play Audio (touchstart)</a>     <a id="playClick">Play Audio (click)</a>     <section id="messages"></section> </body> </html> 

0 Answers

Read More

Tuesday, April 19, 2016

Buttons on navigation bar do not pick up window tint colour

Leave a Comment

I have an Objective-C app that runs on the iPad and displays a view controller with a modal presentation style of UIModalPresentationPageSheet:

UINavigationController *editorNavigationController = [[UINavigationController alloc] initWithRootViewController:editorViewController]; editorNavigationController.modalPresentationStyle = UIModalPresentationPageSheet; [navigationController presentViewController:editorNavigationController animated:YES completion:nil]; 

When this view controller is displayed the buttons in the navigation bar are purple, which I assume has been picked up from the window's tint colour, which is what I want.

Later I need to display another view controller over the top, that fills the whole window:

UINavigationController *previewNavigationController = [[UINavigationController alloc]initWithRootViewController:myPreviewViewController]; [owningViewController presentViewController:previewNavigationController animated:YES completion:nil]; 

The problem I have is that when myPreviewController is displayed, the buttons in the navigation bar are grey. I've tried reinstating the colour on the new navigation controller:

previewNavigationController.navigationBar.tintColor = [UIColor colorWithRed:123/255.0 green:26/255.0 blue:69/255.0 alpha:1]; 

but without any joy.

How can I get the buttons to have the correct colour? Can I get the new navigation controller to pick up the window tint colour automatically, or do I have to set it explicitly? Is this something to do with presenting the second navigation controller over the top of one that uses UIModalPresentationPageSheet?

Any help much appreciated! Thanks,

Paul

2 Answers

Answers 1

You can set the navigationBar translucent and transparent. In view Will Appear:

self.navigationController.navigationBar.translucent = NO; 

Than create a UIView with frame size of navigationBar (CGRectMake(0,0,self.view.frame.size.height,22) and create buttons on it with color you need. I know, thats a crutch but should work)

Answers 2

You can change the appearance of the UIBarButtonItem globally so all UINavigationControllers will share the same design:

[[UIBarButtonItem appearance] setTintColor:[UIColor purpleColor]]; [[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:                                                           [UIFont fontWithName:@"fontName" size:16.0f],NSFontAttributeName,                                                           nil] forState:UIControlStateNormal];  

Additionally you could also change the [UINavigationBar appearance]:

//The setTintColor would tint the < Back button in the NavigationBar  [[UINavigationBar appearance] setTintColor:[UIColor greenColor]]; [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]]; [[UINavigationBar appearance] setTitleTextAttributes:      @{NSForegroundColorAttributeName:[UIColor blueColor]}]; 

This code can be add it before presenting the UIViewControllers or simply in the AppDelegate.m.

Read More

Friday, April 15, 2016

Workaround for overflow restriction affecting fixed-positioned elements in iOS?

Leave a Comment

Edit: The main issue is this: overflow: hidden and overflow: auto affect fixed positioned elements in iOS.

So if I have a fixed positioned modal dialog in a component within a scrolling feature of the page, that element is not displayed wherever it exceeds the bounds of its parent. This is really messed up, as it's not how fixed positioning works on any other system. So what's the official response to this?

Original post:

I have a modal dialog that works fine on desktop and Android, but on any browser on my iPad, the modal dialog, including the modal overlay, gets hidden wherever it exceeds the boundaries of its parent container (even though it is fixed positioned). I know that this isn't how overflow: auto is supposed to work, because it works just fine on all other devices. Anyone else experienced this? I'm sure it has something to do with how iOS handles fixed positions.

Anyway, here's some code:

HTML:

<confirm-dialog ng-if="$ctrl.confirmDlgShowing" on-close="$ctrl.closeDlgs()" on-confirm="$ctrl.deleteInstance()" class="ng-scope ng-isolate-scope">     <div class="modal general modal"><div class="modal-window"><div class="modal-inner" ng-transclude="">        <div style="position:relative" class="ng-scope">         <label class="modal-close" ng-click="$ctrl.onClose()"></label>         <div class="page-heading">             <h2>Are you sure?</h2>         </div>             <input class="btn" type="button" value="Yes" ng-click="$ctrl.confirm()">             <input class="btn" type="button" value="No" ng-click="$ctrl.onClose()">         </div>     </div></div></div> </confirm-dialog> 

SASS:

.container {      overflow: auto;  .modal-window {  // overlay    @include transition(opacity 0.25s ease);    @include position(fixed, 0px 0px 0px 0px);    background: rgba(0,0,0, 0.6);    padding-top: 0.6em;    text-align: left;    z-index: 999999999;    margin: 0 !important;    .modal-bg {       @include position(absolute, 0px 0px 0px 0px);       cursor: pointer;    } }    .modal-inner {   @include transition(opacity 0.25s ease);   background: $modal-background;   border-radius: $base-border-radius;   display: table;   margin: 70px auto;   max-height: 80%;   overflow: auto;   padding: $modal-padding / 2;   z-index: 1000000000;   min-width: 400px;    @media(max-width: $medium-screen) {      max-height: 70%;      padding: $modal-padding;   }  } } 

0 Answers

Read More

Wednesday, March 30, 2016

HTML5 video won't work with jquery bxSlider plugin on iPad

Leave a Comment

I'm using the Jquery bxSlider plugin to create a slider gallery of images and video for the iPad. I'm using the HTML5 video tag for video implementation:

<video width="400" height="260" controls> <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> </video> 

Video source code works fine on iPad when on its own, however when merged with slider markup, the video does not play.

Test link: http://www.ekimmedia.com/totem/TIC/MG/

If I remove this script:

<script src="js/jquery.bxSlider.js" type="text/javascript"></script> 

from the source code, the video then works on iPad.

Test link with bxSlider script removed: http://www.ekimmedia.com/totem/TIC/MG/index10.html

Not sure what is causing the conflict.

Thanks,

3 Answers

Answers 1

The only way how I get this slider to work was to download it locally from the bxslider official website. And try to follow their tutorial on how to make responsive video slider. They do not mention anywhere about these arrow images as they do not come in the css. So, remember to grab an images folder from the downloaded bxslider zip and paste it into js folder of your project.

In my final setup I have had 4 local files in js folder: jquery-2.2.2.min.js, jquery.bxslider.css, jquery.bxslider.js and jquery.fitvids.js. js folder also included images subfolder where were controls.png and bx_loader.gif.

This all was then referenced in HTML file as follows:

<head>   <link rel="stylesheet" href="js/jquery.bxslider.css">   <script src="js/jquery-2.2.2.min.js"></script>   <script src="js/jquery.fitvids.js"></script>   <script src="js/jquery.bxslider.js"></script>   <script type="text/javascript">     $(document).ready(function () {     $('.bxslider').bxSlider({     video: true,     useCSS: false     });     });   </script> </head> <body>     <ul class="bxslider">         <li>             <iframe src="YOUR_LINK_TO_VIDEO" width="400" height="260" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>         </li>         <li>             <iframe src="YOUR_LINK_TO_VIDEO" width="400" height="260" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>         </li>     </ul> </body> 

I have tested my solution on iOS device and everything seems to work fine. There is somewhat similar solution to this problem, you can also look into it.

Answers 2

Try viewing the video element with a debugging tool like firebug or safari developer tools. You may have to use a PC/Mac browser to do this. See if the video element loses any attributes, or gets extra things added after your jquery script runs. Having done some mobile development involving videos I can tell you it is very touchy, especially since there are approximately 82 billion different browsers and OS versions floating around on mobile devices. If you see that the video element is changed, then you will need to add a script that takes it back to something viewable on your iPad.

You might also make sure your videos are wrapped correctly. It looks like this slider script requires the following format:

<div id="slideshowcontainer">  <div>slide1 content</div>  <div>slide2 content</div>  <div>etc...</div> </div>  OR  <ul id="slideshowcontainer">  <li>slide1 content</li>  <li>slide2 content</li>  <li>etc...</li> </ul> 

Answers 3

Try to change the position of

 `<script src="js/jquery.bxSlider.js" type="text/javascript"></script>` 

my be it is due to confliction of libraries, put it in middle of all scripts or in bottom or anywhere elc, i am sure it gona work.

Read More

Sunday, March 27, 2016

Different size classes for iPad portal and landscape modes with containerviews

Leave a Comment

I've found this question and I've tried to implement the solution that has been given. However I run into a problem.

My initial view controller has two container views who both have their own view controller. I've created a root view controller that is assigned to the initial view controller. The code in this class looks like this.

class RootViewController: UIViewController {  var willTransitionToPortrait: Bool! var traitCollection_CompactRegular: UITraitCollection! var traitCollection_AnyAny: UITraitCollection!  override func viewDidLoad() {     super.viewDidLoad()     setupReferenceSizeClasses()     // Do any additional setup after loading the view. }  override func viewWillAppear(animated: Bool) {     willTransitionToPortrait = self.view.frame.size.height > self.view.frame.size.width }  override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {     willTransitionToPortrait = size.height > size.width }  func setupReferenceSizeClasses(){     let traitCollection_hCompact = UITraitCollection(horizontalSizeClass: .Compact)     let traitCollection_vRegular = UITraitCollection(verticalSizeClass: .Regular)     traitCollection_CompactRegular = UITraitCollection(traitsFromCollections: [traitCollection_hCompact, traitCollection_vRegular])      let traitCollection_hAny = UITraitCollection(horizontalSizeClass: .Unspecified)     let traitCollection_vAny = UITraitCollection(verticalSizeClass: .Unspecified)     traitCollection_AnyAny = UITraitCollection(traitsFromCollections: [traitCollection_hAny, traitCollection_vAny]) }  override func overrideTraitCollectionForChildViewController(childViewController: UIViewController) -> UITraitCollection? {     let traitCollectionForOverride = ((willTransitionToPortrait) != nil) ? traitCollection_CompactRegular : traitCollection_AnyAny      return traitCollectionForOverride; } 

However when I run it the size class won't respons like it should. One of the container view controllers will start acting weird in both landscape and portrait mode like can be seen below.

landscape mode portrait mode

When I don't assign the rootviewcontroller it will look like this landscape mode portrait mode

While it should look like this in portrait mode portrait mode how it should look

Does anyone know what might be going wrong here? Why it doesn't change the size class like desired.

EDIT Like @Muhammad Yawar Ali asked here are screenshots from the position of all the size classes I've set. I have no warnings or errors on any constraints so these screenshots contain the updated views.

enter image description here enter image description here

I hope this shows everything that is needed.

EDIT: for some reason I'm unable to put in all the screenshots

2 Answers

Answers 1

On the viewWillTransitionToSize you need to call also super, to pass the event to the next responder (your rootviewcontroller)...

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {     super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)     willTransitionToPortrait = size.height > size.width } 

Answers 2

I have cloned your code from repository : https://github.com/MaikoHermans/sizeClasses.git And editted code put the below code in you controller it will work fine & will not effect your design in iPads. import UIKit

class RootViewController: UIViewController {     override func viewDidLoad() {       super.viewDidLoad()       // Do any additional setup after loading the view.    }     override func overrideTraitCollectionForChildViewController(childViewController: UIViewController) -> UITraitCollection? {       if view.bounds.width < view.bounds.height {          return UITraitCollection(horizontalSizeClass: .Unspecified)       } else {          return UITraitCollection(horizontalSizeClass: .Regular)       }    } } 

You can try with this code but There is an issue i believe its not updating traits properly for ipads and view layout remains same but looks good. I have tried multiple ways but not succeeded yet will update my answer.

Read More

Monday, March 7, 2016

jQuery Selectric bug on iPad

Leave a Comment

I use jQuery Selectric plugin for customize select's.

$('select').selectric({   disableOnMobile: false }); 

If i open select on iPad device my left column move up

.left-column {   position: fixed;   left: 0;   top: 0;   width: 200px;   height: 100vh;   background: #F00;   z-index: 100; } 

Please, help with it. Demo here: http://output.jsbin.com/seleyi

enter image description here

UPD: test at browserstack iOS < 7 - no problem, iOS 8.3 - have some problem, iOS 9.1 have this bug

0 Answers

Read More