How do I code a specific array element in section (GroupBy)?
in editingStyle, lists.remove(at: indexPath.row) moved the wrong element.
Help..
Post
Replies
Boosts
Views
Activity
While trying to upload the App to App Store Connect, I received this error message:
App Store Connect Operation Error
RATE_LIMIT_EXCEEDED: The request rate limit has been reached.
What it means? And, how do I fix it?
Thanks.
I have an alertController, with one textField.. and alertAction button [Save].
When the textField presented (empty), the [Save].isEnabled = false.
If user type anything in textField (none space), button [Save].isEnabled = true.
code:
field.addTarget(self, action: #selector(self.alertTextFieldDidChange(_:)), for: .editingChanged)
validation code:
var alertController : UIAlertController?
@objc func alertTextFieldDidChange(_ sender: UITextField) {
alertController?.actions[0].isEnabled = sender.text!.trimmingCharacters(in: .whitespacesAndNewlines).count > 0
}
[Save] button works as expected.
However, when I insert text in textField (as default entry):
textField.text = "Test"
textField showing "Text", if user choose to accept the default value "Test", [Save] button isEnabled will not change. User will have to type something in textField.
I need some direction .. Thanks.
Here's basic code of my ToDo App:
Data:
struct ToDo: Codable {
var title: String
var isCompleted: Bool
var dateCreated: Date
var notes: String
static let DocumentsDirectory =
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
static let ArchiveURL = DocumentsDirectory.appendingPathComponent("todos") .appendingPathExtension("plist")
static func loadToDos() -> [ToDo]? {
guard let codedToDos = try? Data(contentsOf: ArchiveURL) else {return nil}
let propertyListDecoder = PropertyListDecoder()
return try? propertyListDecoder.decode(Array<ToDo>.self, from: codedToDos)
}
static func saveToDos(_ todos: [ToDo]) {
let propertyListEncoder = PropertyListEncoder()
let codedToDos = try? propertyListEncoder.encode(todos)
try? codedToDos?.write(to: ArchiveURL,
options: .noFileProtection)
}
I have a tableViewController to display the data's detail, there's a noteTextView (textView) for editing/adding the todo.note. There's a Camera Button allows user to insert the images into (textView) todo.note using NSTextAttachment():
internal func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let attachment = NSTextAttachment()
let image = info[.originalImage] as! UIImage
attachment.image = image
//Resize Photo to fit in noteTextView: calculate new size so want a litter space on the right of image
let newImageWidth = (noteTextView.bounds.size.width - 20)
let scale = newImageWidth/image.size.width
let newImageHeight = image.size.height * scale
attachment.bounds = CGRect.init(x: 0, y: 0, width: newImageWidth, height: newImageHeight)
//attributedString=NSTextAttachment()
let imageString = NSAttributedString(attachment: attachment)
// add this attributed string to the cusor position
noteTextView.textStorage.insert(imageString, at: noteTextView.selectedRange.location)
picker.dismiss(animated: true, completion: nil)
}
The code working well. Now, how do I save it (with images) to DocumentsDirectory and how do I load it back? I can save/load without images.
Thanks.
For a tableView: I try to change my code from using cell.textLabel to cell.contentConfiguration, we can't get the same result as before (using cell.textLabel), I like to keep the row heigh at 20, the old code display nicely, but the new code won't be able to show it at all unless I use row height 40. Here's the code:
import UIKit
var fruites = ["Apple","Orange","PineApple", "Water Melon", "Banana"]
class ViewController: UIViewController {
@IBOutlet weak var tblTableViewA: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tblTableViewA.dataSource = self
tblTableViewA.delegate = self
}
}
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruites.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellA", for: indexPath)
let fruit = fruites[indexPath.row]
// New code does not display right, content does not display properly like old code. when row height = 20, it won't even show.
/*
var content = cell.defaultContentConfiguration()
content.textProperties.adjustsFontSizeToFitWidth = true
content.text = fruit
cell.contentConfiguration = content
*/
// Old code works perfect
cell.textLabel?.adjustsFontSizeToFitWidth = true
cell.textLabel!.text = fruit
return cell
}
extension ViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return 20 //CGFloat(20)
}
}
Thanks in advance!
Today I upload my App new release to TestFlight, then use my phone to test it. But the App will not load. I reset the phone few times, it seems trying to load but stopped loading.
I compile the App on my local Mac and the same phone, works fine.
Any suggestions?
Thanks!
After update iPhone iOS to 16, when I start Xcode, it 'Failed to prepare device for development'. I have restarted both device (macOS Big Sur 11.7) several time still not working. Xcode version 13.2.1.
The project is to create QRCode for digital vCard. I've generated QRCode for following contact fields and be able to be read by iPhone camera:
Name(N:), Telephone(TEL:), Email(Email:), url(URL:) and Note(NOTE:)
But no luck on fields: Company, Address, Social Profile and photo:
textToQRCode = "BEGIN:VCARD\n" +
"N:\(lastName);\(firstName)\n" +
"TEL:\(phoneNumber)\n" +
"Email:\(email)\n" +
"NOTE:\(notes)\n" +
"END:VCARD"
Any suggestions?
Thanks!
I keep several different versions of my App under development. After upgrade MacOS to 13.4, I no log can load project with SDK errors. Example, If my project folder(where I keep my project files) name was "ABC v2.12", I change the name to "ABC v2.13" it causing error:
/Volumes/MicroSDXC256/Programming/ABC v2.13/ABC.xcodeproj Missing package product 'FirebaseDatabaseSwift'
I have a textView in the Main storyboard where I've enabled the data detector for Flight Number and disabled editing. When the textView is presented, the user can tap the flight number link. It displays a dialog with a map and a UIMenu for Preview Flight. However, when I select Preview Flight, it shows nothing but 'Flight information unavailable'. I tried the same flight number on Apple Notes, and it works fine.
Today, I can no longer create a new version for my Apps. Getting "An error has occurred. Try again later"...
This has never happened to me before.