Answer the question
In order to leave comments, you need to log in
Size ContentSize in UIScrollView iOS. How to align to content size?
Hello. I'm new to Apple development and faced such a problem - there is a uiscrollview on the controller and on it there are several elements that are created dynamically (for example, a button and after the button a tableview that has an unknown size in advance, because the data is pulled from the server). How can I make the ContentSize size be calculated from the height of the content? Now it turns out that sometimes the scroll may not reach the end of the tableview, but it may be much lower.
Answer the question
In order to leave comments, you need to log in
UITableView is a descendant of UIScrollView. Remove the scroll and leave only the table. Put your button in the first cell of the table, and proceed with the rest of the cells as you did before. To do this, however, you will need to use a separate reuseIdentifier for the cell with the button.
Or put the button in the headerView of the table. In general, in your case, one way or another, UIScrollView is not needed. Take a closer look at working with UITableView: sections, table headers/footers, section headers/footers, different cells and their prototypes. I'm sure a lot will fall into place.
In the symbols
variable , in my opinion, there is no special meaning, due to the presence of the punctuation module .
Checking for the presence of a character/s can be done with a list comprehension , for example, and, depending on the result, output, conditionally, Yes or No .
In summary, try:
>>> from string import punctuation
>>> def check_spec_characters(text):
res = [i for i in punctuation if i in text]
if res:
print('YES')
else:
print('NO')
>>> text = 'Expression syntax is straightforward: the operators +, -, * and / work as expected'
>>> check_spec_characters(text)
YES
>>> text = 'Expression syntax is straightforward the operators work as expected'
>>> check_spec_characters(text)
NO
......
if res:
print('Special characters found in text: {}'.format(res))
......
>>> text = 'Expression syntax is straightforward: the operators +, -, * and / work as expected'
>>> check_spec_characters(text)
Special characters found in text: ['*', '+', ',', '-', '/', ':']
Because the exit from the function occurs at the first iteration, with the result of checking the first letter.
char_is_special = frozenset("[ ~`[email protected]#$%^&*()_-+={}[]:>;',</?*-+ ]").__contains__
def str_has_special(s):
return any(map(char_is_special, s))
print(char_is_special("a"), char_is_special("?"))
print(str_has_special("abc"), str_has_special("abc?"))
for every_character in symbols:
if every_character in entered:
return 1
else:
return 0
First of all , the if every_character in entered: check confuses , why do you need to cycle through every_character then ?
entered = str(input('Enter the string: '))
symbols = "[ ~`[email protected]#$%^&*()_-+={}[]:>;',</?*-+ ]"
def check_spec_characters(entered):
for every_character in entered:
if every_character in symbols:
return 1
else:
return 0
check_spec_characters(entered)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question