iOS Programming

Subscribe to iOS Programming feed
A subreddit to share articles, code samples, open source projects and anything else related to iOS, watchOS or tvOS development. Swift or Objective-C.iOS Programming
Updated: 26 min 54 sec ago

Have a textView with a vertical slider that shows relative position in text. Implemented tap gesture to make textView fullscreen, but when textView reverses back to original size, slider skips forward

5 hours 9 min ago

Here's a screenrecording of the issue - https://imgur.com/a/CsVpk6b

When I tap to make textView its original size, you see the slider skip forward as the text also skips forward, and it all feels glitchy. I need a better way - how can I have the text (and uislider) stay at the same position? The textView shows text from a .txt file in app bundle.

Here's my relevant code:

class TextViewController: UIViewController {

var stories: [URL] = [] var isHidden = false var textViewHeight = Double() var textViewWidth = Double() var textViewX = Double() var textViewY = Double() @IBOutlet var mainView: UIView! @IBOutlet var textView: UITextView! @IBOutlet weak var textSlider: UISlider! { didSet { configureSlider() }} override func viewDidLoad() { super.viewDidLoad() loadTextAndTitle() configureSlider() } //Mark: - Load story, setup textview func loadTextAndTitle() { DispatchQueue.global().async { let storyText = try? String(contentsOf: self.selectedStory) DispatchQueue.main.async { self.textView.text = storyText } } let storyTitle = selectedStory.deletingPathExtension().lastPathComponent storyTitleLabel.title = storyTitle textView.delegate = self textView.textContainerInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0) textView.isScrollEnabled = false //Force textView scroll to start at 0 toolbar.clipsToBounds = true let tapTextView = UITapGestureRecognizer(target: self, action: #selector(BaniViewController.textViewTapped)) textView.isUserInteractionEnabled = true textView.addGestureRecognizer(tapTextView) } //Mark: - Force textView scroll to start at 0 at load, an imperfect method/look for better. Also store textview coordinates to use in tap gesture to full screen override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) textView.isScrollEnabled = true let widthOfTextView = textView.frame.width textViewWidth = Double(widthOfTextView) let heightOfTextView = textView.frame.height textViewHeight = Double(heightOfTextView) let xOfTextView = textView.frame.origin.x + view.frame.origin.x textViewX = Double(xOfTextView) let yOfTextView = textView.frame.origin.y + view.frame.origin.y textViewY = Double(yOfTextView) } //Mark: - UITapGestureRecognized for hiding Toolbar, Status&Navigation Bar, slider @objc func textViewTapped(_ sender: UITapGestureRecognizer) { toolbar.isHidden = toolbar.isHidden ? false : true textSlider.isHidden = textSlider.isHidden ? false : true navigationController!.setNavigationBarHidden(!isHidden, animated: false) isHidden = navigationController!.isNavigationBarHidden self.setNeedsStatusBarAppearanceUpdate() let viewWidth = view.frame.width let viewHeight = view.frame.height print(viewWidth, "viewWidth") if textView.frame.width == view.frame.width { // text view is full size, animate back to normal size let animator = UIViewPropertyAnimator(duration: 0.5, curve: .easeOut, animations: { sender.view!.frame = CGRect(x: self.textViewX, y: self.textViewY, width: self.textViewWidth, height: self.textViewHeight) }) animator.startAnimation() } else { // text view is normal size, animate to full size let animator = UIViewPropertyAnimator(duration: 0.5, curve: .easeIn, animations: { sender.view!.frame = CGRect(x: 0, y: 0, width: viewWidth, height: viewHeight) }) animator.startAnimation() } } override var prefersStatusBarHidden: Bool { return isHidden } //Mark: - Configure text reading slider func configureSlider() { textSlider.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi / 2)) textSlider.setThumbImage(UIImage(named: "textsliderthumb.png")!, for: .normal) } @IBAction func sliderValueChanged(_ sender: UISlider) { let contentSize = textView.contentSize.height let yPosition = contentSize * CGFloat(sender.value) textView.setContentOffset(CGPoint(x: 0, y: yPosition), animated: true) } } //Mark: - Set textView position = scrollView thumb on textSlider by calculating insets extension UIScrollView { var minContentOffset: CGPoint { return CGPoint(x: -self.contentInset.left, y: -self.contentInset.top) } var maxContentOffset: CGPoint { return CGPoint(x: self.contentSize.width - self.bounds.width + self.contentInset.right, y: self.contentSize.height - self.bounds.height + self.contentInset.bottom) } } extension TextViewController: UITextViewDelegate { } extension TextViewController: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { if scrollView === textView { let diffOffsetY = scrollView.contentOffset.y - scrollView.minContentOffset.y let totalOffset = scrollView.maxContentOffset.y - scrollView.minContentOffset.y let sliderRange = self.textSlider.maximumValue - self.textSlider.minimumValue textSlider.value = textSlider.minimumValue + Float(diffOffsetY / totalOffset) * sliderRange } } } submitted by /u/hugmeiaffiliate
[link] [comments]

Scripts to check App Store Connect errors

5 hours 11 min ago

So I'm sure I'm not the only one; you test your app and you feel this is a good new version. Maybe you push it to Connect just for Testflight, maybe it's meant for production. Either way, you're going to have to pass the review. And before that, your binary has to conform to some standards.

At work I take care of a big part of the deployment. Some people build apps in Ionic, some in React Native. Some of these still fail to generate the 1024px icon for the App Store. Some don't put the right info.plist keys for permissions. All of this results in a valid app binary that gets through tests, but will be denied by Apple. Every time this happens, you have to submit a new build.

What I'm looking for is some sort of tool/script that checks the project for some (or all) of these things; does it have all the right icons, does it contain the right keys (probably for a given selection of features), etc. Has anyone here ever used something like this? Thanks!

submitted by /u/David_Edward_King
[link] [comments]

Anyone use RxSwift?

7 hours 1 min ago

I'm doing an RW tutorial on it right now, it looks really interesting. However, I've also just done some some other observable work.

Q1. Why use RxSwift vs a custom property observer?

Q2. Is there any limit to what it can observe, example Core Data field, Realm/FireBase field, data change from some API you link to?

He has the example of stock prices, so I guess you can set a listener on any external data source?

Edit: here's the link if anyone is interested: https://www.youtube.com/watch?v=W3zGx4TUaCE

submitted by /u/KarlJay001
[link] [comments]

How can I possibly create an array of integers and store it in core data so it acts as an attribute to an entity?

Thu, 09/20/2018 - 23:32

Workout app I am working on:

entity named WorkoutEntity:

attributes of WorkoutEntity:
-name:String
-sets:Int
-reps:Int
-currentSet:Int

Basically I want the user to be able to choose different amounts of reps for each set of a workout. This means I will need to make reps of type [Int], to hold multiple values of reps. I tried doing it in a string and parsing and unparsing, but it became disastrous. Any tips you'd recommend? *The only rule is that it can't just be stored in a random array, it must be stored in core data* Thanks!

submitted by /u/cupojoe4me
[link] [comments]

Anyone interested in tools for building decentralized native apps? What tools would be most helpful?

Thu, 09/20/2018 - 17:05

We have been working hard to create Textile Photos (r/https://textile.photos) as decentralized as possible as a native application. We've solved some really cool problems (decentralized networking & communication protocols, connecting to IPFS for media and storage).

It's all already open source (r/https://github.com/textileio), but now, we want to box some of those up into nice, reusable packages. We are road mapping out a simple single sign-on (simplify on-boarding by integrating Goog, FB _and_ blockstack, uport, etc) for account creation, profile and account data management, session data, personal data recovery, and a host of others.

Is anyone here interested in this space? Any packages you would already be eager to use?

submitted by /u/andrewxhill
[link] [comments]

Does anyone know a great UI & app icon designer?

Thu, 09/20/2018 - 16:23

Title says it all. I'm looking for a new UI design and app icon for my iOS + Android app.

Unfortunately, designers from platforms such as Dribbble or Behance have often been disappointing.

Thanks!

submitted by /u/_johnlocke_
[link] [comments]

How to create a quick VR game?

Thu, 09/20/2018 - 14:40

My work has asked me to develop a simple VR game, it can be anything really but they might also want some questions to be displayed for the user to answer as they are playing. This is not essential however. I’m not familiar with making VR games at all so wanted to ask if anyone knew of any easy implementations I can wow my boss with?

submitted by /u/KWAK3_
[link] [comments]

Can't remotely deploy app until it's been deployed via xCode to that specific device?

Thu, 09/20/2018 - 12:59

Happy Thursday Folks, it's almost Friday, Yay!

When I use TestFlight, MDM, iTunes, etc to install my Dev-Build.ipa on a remote device, I just get a 'failed to install' error.

The only way it installs through the above methods is by compiling / pushing the code via xCode locally to the device and then deleting it. Once deleted it's able to properly install & run through the above methods.

submitted by /u/DarkDevildog
[link] [comments]

Swift MongoDB Server - The data couldn’t be read because it isn’t in the correct format. Potential Connection error or type error?

Thu, 09/20/2018 - 12:54

I am developing a simple application with a login screen. In the code for my view controller (LoginViewController) I created the following function, which should allow a user to sign up. However, when I test the application, the console tells me "The data couldn't be read because it isn't in the correct format."

@IBAction func onSignUp(_ sender: Any) { let newUser = PFUser() newUser.username = usernameField.text as String! newUser.password = passwordField.text as String! newUser.signUpInBackground { (success: Bool, error: Error?) in if success { print("Created User") } else { print(error!.localizedDescription) } } }

I suspect that im running into a type error of some kind? Does the text field expect a data type other than a string? Any idea as to why this is happening? Any known solutions?

submitted by /u/ParksideAdrian
[link] [comments]

Is it possible to have an app that overlays itself – similarly to AssistiveTouch?

Thu, 09/20/2018 - 10:42

I’d like to be able to map keyboard shortcuts to parts of the iPhone screen, my idea was to have a menu (like assistiveTouch) that could create boxes which would be bound to a key. The boxes could then be moved around the screen so that a key press would simulate tapping that part of the screen.

Is something like this possible? What APIs should I look into?

submitted by /u/DirewolfMiner
[link] [comments]

Anyone know where the source code for this RW tutorial is?

Thu, 09/20/2018 - 10:04

https://www.youtube.com/watch?v=IVYsT7gU6PQ

Here's a pretty good Autolayout tutorial, but they didn't link the code. They give the RW site as a link, but they have TONS of tutorials there and I can't find the actual link to the source.

submitted by /u/KarlJay001
[link] [comments]

My Mac is now unsupported with the latest macOS. Can I still use Xcode/build iOS apps/publish on App Store?

Thu, 09/20/2018 - 08:50

Hi all. I own a MacBook Pro mid-2010 that is now unsuppported with macOS Mojave. I wanted to get into iOS development, but am now wondering whether I need a new Mac to do so. Does the macOS version matter when developing? What could (or couldn't) I do? Limitations? Caveats?

submitted by /u/ideaman924
[link] [comments]

Still possible to make money with side projects?

Thu, 09/20/2018 - 06:41

The market seems very saturated in general so I’m just curious if it’s possible (or if anyone here has any examples) to make money as a sole developer working on some side app projects?

I have a friend who used to make £400 a month with a simple Reddit clone years ago from ad revenue.

Thoughts?

submitted by /u/bustyLaserCannon
[link] [comments]

Pages